2

-std=c++11次のコードは、フラグが設定されている場合、g++ 4.7.3 でのコンパイルに失敗します(下部にエラー メッセージが貼り付けられています)。

#include <boost/variant.hpp>
#include <boost/shared_ptr.hpp>

int main() {
    boost::shared_ptr<int> i;
    boost::variant< boost::shared_ptr<int> > v;
    v = i;

    return 0;
}

Boost のバージョンは 1.54 です。std=c++11が設定されていない場合でも、clang 3.4 ( の有無にかかわらず) でもエラーなしでコンパイルされます-std=c++11。これは有効なコードであると確信していますが、これは g++ の問題ですか、それともブーストの問題ですか? もしそうなら、バグは正確には何ですか?

エラーメッセージは次のとおりです。

In file included from /usr/local/include/boost/variant.hpp:17:0,
                 from vartest.cpp:1:
/usr/local/include/boost/variant/variant.hpp: In instantiation of ‘void boost::variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19>::move_assigner::internal_visit(RhsT&, int) [with RhsT = boost::shared_ptr<int>; T0_ = boost::shared_ptr<int>; T1 = boost::detail::variant::void_; T2 = boost::detail::variant::void_; T3 = boost::detail::variant::void_; T4 = boost::detail::variant::void_; T5 = boost::detail::variant::void_; T6 = boost::detail::variant::void_; T7 = boost::detail::variant::void_; T8 = boost::detail::variant::void_; T9 = boost::detail::variant::void_; T10 = boost::detail::variant::void_; T11 = boost::detail::variant::void_; T12 = boost::detail::variant::void_; T13 = boost::detail::variant::void_; T14 = boost::detail::variant::void_; T15 = boost::detail::variant::void_; T16 = boost::detail::variant::void_; T17 = boost::detail::variant::void_; T18 = boost::detail::variant::void_; T19 = boost::detail::variant::void_]’:
/usr/local/include/boost/variant/detail/visitation_impl.hpp:130:9:   required from ‘typename Visitor::result_type boost::detail::variant::visitation_impl_invoke_impl(int, Visitor&, VoidPtrCV, T*, mpl_::true_) [with Visitor = boost::variant<boost::shared_ptr<int> >::move_assigner; VoidPtrCV = void*; T = boost::shared_ptr<int>; typename Visitor::result_type = void; mpl_::true_ = mpl_::bool_<true>]’
/usr/local/include/boost/variant/detail/visitation_impl.hpp:173:9:   required from ‘typename Visitor::result_type boost::detail::variant::visitation_impl_invoke(int, Visitor&, VoidPtrCV, T*, NoBackupFlag, int) [with Visitor = boost::variant<boost::shared_ptr<int> >::move_assigner; VoidPtrCV = void*; T = boost::shared_ptr<int>; NoBackupFlag = boost::variant<boost::shared_ptr<int> >::has_fallback_type_; typename Visitor::result_type = void]’
/usr/local/include/boost/variant/detail/visitation_impl.hpp:260:1:   required from ‘typename Visitor::result_type boost::detail::variant::visitation_impl(int, int, Visitor&, VoidPtrCV, mpl_::false_, NoBackupFlag, Which*, step0*) [with Which = mpl_::int_<0>; step0 = boost::detail::variant::visitation_impl_step<boost::mpl::l_iter<boost::mpl::l_item<mpl_::long_<1l>, boost::shared_ptr<int>, boost::mpl::l_end> >, boost::mpl::l_iter<boost::mpl::l_end> >; Visitor = boost::variant<boost::shared_ptr<int> >::move_assigner; VoidPtrCV = void*; NoBackupFlag = boost::variant<boost::shared_ptr<int> >::has_fallback_type_; typename Visitor::result_type = void; mpl_::false_ = mpl_::bool_<false>]’
/usr/local/include/boost/variant/variant.hpp:2326:13:   required from ‘static typename Visitor::result_type boost::variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19>::internal_apply_visitor_impl(int, int, Visitor&, VoidPtrCV) [with Visitor = boost::variant<boost::shared_ptr<int> >::move_assigner; VoidPtrCV = void*; T0_ = boost::shared_ptr<int>; T1 = boost::detail::variant::void_; T2 = boost::detail::variant::void_; T3 = boost::detail::variant::void_; T4 = boost::detail::variant::void_; T5 = boost::detail::variant::void_; T6 = boost::detail::variant::void_; T7 = boost::detail::variant::void_; T8 = boost::detail::variant::void_; T9 = boost::detail::variant::void_; T10 = boost::detail::variant::void_; T11 = boost::detail::variant::void_; T12 = boost::detail::variant::void_; T13 = boost::detail::variant::void_; T14 = boost::detail::variant::void_; T15 = boost::detail::variant::void_; T16 = boost::detail::variant::void_; T17 = boost::detail::variant::void_; T18 = boost::detail::variant::void_; T19 = boost::detail::variant::void_; typename Visitor::result_type = void]’
/usr/local/include/boost/variant/variant.hpp:2337:13:   required from ‘typename Visitor::result_type boost::variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19>::internal_apply_visitor(Visitor&) [with Visitor = boost::variant<boost::shared_ptr<int> >::move_assigner; T0_ = boost::shared_ptr<int>; T1 = boost::detail::variant::void_; T2 = boost::detail::variant::void_; T3 = boost::detail::variant::void_; T4 = boost::detail::variant::void_; T5 = boost::detail::variant::void_; T6 = boost::detail::variant::void_; T7 = boost::detail::variant::void_; T8 = boost::detail::variant::void_; T9 = boost::detail::variant::void_; T10 = boost::detail::variant::void_; T11 = boost::detail::variant::void_; T12 = boost::detail::variant::void_; T13 = boost::detail::variant::void_; T14 = boost::detail::variant::void_; T15 = boost::detail::variant::void_; T16 = boost::detail::variant::void_; T17 = boost::detail::variant::void_; T18 = boost::detail::variant::void_; T19 = boost::detail::variant::void_; typename Visitor::result_type = void]’
/usr/local/include/boost/variant/variant.hpp:2109:13:   required from ‘void boost::variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19>::variant_assign(boost::variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19>&&) [with T0_ = boost::shared_ptr<int>; T1 = boost::detail::variant::void_; T2 = boost::detail::variant::void_; T3 = boost::detail::variant::void_; T4 = boost::detail::variant::void_; T5 = boost::detail::variant::void_; T6 = boost::detail::variant::void_; T7 = boost::detail::variant::void_; T8 = boost::detail::variant::void_; T9 = boost::detail::variant::void_; T10 = boost::detail::variant::void_; T11 = boost::detail::variant::void_; T12 = boost::detail::variant::void_; T13 = boost::detail::variant::void_; T14 = boost::detail::variant::void_; T15 = boost::detail::variant::void_; T16 = boost::detail::variant::void_; T17 = boost::detail::variant::void_; T18 = boost::detail::variant::void_; T19 = boost::detail::variant::void_; boost::variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19> = boost::variant<boost::shared_ptr<int> >]’
/usr/local/include/boost/variant/variant.hpp:2130:13:   required from ‘void boost::variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19>::assign(const T&) [with T = boost::shared_ptr<int>; T0_ = boost::shared_ptr<int>; T1 = boost::detail::variant::void_; T2 = boost::detail::variant::void_; T3 = boost::detail::variant::void_; T4 = boost::detail::variant::void_; T5 = boost::detail::variant::void_; T6 = boost::detail::variant::void_; T7 = boost::detail::variant::void_; T8 = boost::detail::variant::void_; T9 = boost::detail::variant::void_; T10 = boost::detail::variant::void_; T11 = boost::detail::variant::void_; T12 = boost::detail::variant::void_; T13 = boost::detail::variant::void_; T14 = boost::detail::variant::void_; T15 = boost::detail::variant::void_; T16 = boost::detail::variant::void_; T17 = boost::detail::variant::void_; T18 = boost::detail::variant::void_; T19 = boost::detail::variant::void_]’
/usr/local/include/boost/variant/variant.hpp:2168:9:   required from ‘boost::variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19>& boost::variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19>::operator=(const T&) [with T = boost::shared_ptr<int>; T0_ = boost::shared_ptr<int>; T1 = boost::detail::variant::void_; T2 = boost::detail::variant::void_; T3 = boost::detail::variant::void_; T4 = boost::detail::variant::void_; T5 = boost::detail::variant::void_; T6 = boost::detail::variant::void_; T7 = boost::detail::variant::void_; T8 = boost::detail::variant::void_; T9 = boost::detail::variant::void_; T10 = boost::detail::variant::void_; T11 = boost::detail::variant::void_; T12 = boost::detail::variant::void_; T13 = boost::detail::variant::void_; T14 = boost::detail::variant::void_; T15 = boost::detail::variant::void_; T16 = boost::detail::variant::void_; T17 = boost::detail::variant::void_; T18 = boost::detail::variant::void_; T19 = boost::detail::variant::void_; boost::variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19> = boost::variant<boost::shared_ptr<int> >]’
vartest.cpp:7:9:   required from here
/usr/local/include/boost/variant/variant.hpp:2058:13: error: no matching function for call to ‘boost::variant<boost::shared_ptr<int> >::move_assigner::assign_impl(boost::shared_ptr<int>&, nothrow_copy, nothrow_move_constructor, boost::variant<boost::shared_ptr<int> >::has_fallback_type_)’
/usr/local/include/boost/variant/variant.hpp:2058:13: note: candidates are:
/usr/local/include/boost/variant/variant.hpp:1959:14: note: template<class RhsT, class B1, class B2> void boost::variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19>::move_assigner::assign_impl(RhsT&, mpl_::true_, mpl_::false_, B2) [with RhsT = RhsT; B1 = B1; B2 = B2; T0_ = boost::shared_ptr<int>; T1 = boost::detail::variant::void_; T2 = boost::detail::variant::void_; T3 = boost::detail::variant::void_; T4 = boost::detail::variant::void_; T5 = boost::detail::variant::void_; T6 = boost::detail::variant::void_; T7 = boost::detail::variant::void_; T8 = boost::detail::variant::void_; T9 = boost::detail::variant::void_; T10 = boost::detail::variant::void_; T11 = boost::detail::variant::void_; T12 = boost::detail::variant::void_; T13 = boost::detail::variant::void_; T14 = boost::detail::variant::void_; T15 = boost::detail::variant::void_; T16 = boost::detail::variant::void_; T17 = boost::detail::variant::void_; T18 = boost::detail::variant::void_; T19 = boost::detail::variant::void_]
/usr/local/include/boost/variant/variant.hpp:1959:14: note:   template argument deduction/substitution failed:
/usr/local/include/boost/variant/variant.hpp:2058:13: note:   couldn't deduce template parameter ‘B1’
/usr/local/include/boost/variant/variant.hpp:1978:14: note: template<class RhsT, class B> void boost::variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19>::move_assigner::assign_impl(RhsT&, mpl_::true_, mpl_::true_, B) [with RhsT = RhsT; B = B; T0_ = boost::shared_ptr<int>; T1 = boost::detail::variant::void_; T2 = boost::detail::variant::void_; T3 = boost::detail::variant::void_; T4 = boost::detail::variant::void_; T5 = boost::detail::variant::void_; T6 = boost::detail::variant::void_; T7 = boost::detail::variant::void_; T8 = boost::detail::variant::void_; T9 = boost::detail::variant::void_; T10 = boost::detail::variant::void_; T11 = boost::detail::variant::void_; T12 = boost::detail::variant::void_; T13 = boost::detail::variant::void_; T14 = boost::detail::variant::void_; T15 = boost::detail::variant::void_; T16 = boost::detail::variant::void_; T17 = boost::detail::variant::void_; T18 = boost::detail::variant::void_; T19 = boost::detail::variant::void_]
/usr/local/include/boost/variant/variant.hpp:1978:14: note:   template argument deduction/substitution failed:
/usr/local/include/boost/variant/variant.hpp:2058:13: note:   cannot convert ‘nothrow_move_constructor()’ (type ‘nothrow_move_constructor {aka boost::integral_constant<bool, false>}’) to type ‘mpl_::true_ {aka mpl_::bool_<true>}’
/usr/local/include/boost/variant/variant.hpp:1997:14: note: template<class RhsT> void boost::variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19>::move_assigner::assign_impl(RhsT&, mpl_::false_, mpl_::false_, mpl_::true_) [with RhsT = RhsT; T0_ = boost::shared_ptr<int>; T1 = boost::detail::variant::void_; T2 = boost::detail::variant::void_; T3 = boost::detail::variant::void_; T4 = boost::detail::variant::void_; T5 = boost::detail::variant::void_; T6 = boost::detail::variant::void_; T7 = boost::detail::variant::void_; T8 = boost::detail::variant::void_; T9 = boost::detail::variant::void_; T10 = boost::detail::variant::void_; T11 = boost::detail::variant::void_; T12 = boost::detail::variant::void_; T13 = boost::detail::variant::void_; T14 = boost::detail::variant::void_; T15 = boost::detail::variant::void_; T16 = boost::detail::variant::void_; T17 = boost::detail::variant::void_; T18 = boost::detail::variant::void_; T19 = boost::detail::variant::void_]
/usr/local/include/boost/variant/variant.hpp:1997:14: note:   template argument deduction/substitution failed:
/usr/local/include/boost/variant/variant.hpp:2058:13: note:   cannot convert ‘nothrow_copy()’ (type ‘nothrow_copy {aka mpl_::bool_<true>}’) to type ‘mpl_::false_ {aka mpl_::bool_<false>}’
/usr/local/include/boost/variant/variant.hpp:2033:14: note: template<class RhsT> void boost::variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19>::move_assigner::assign_impl(const RhsT&, mpl_::false_, mpl_::false_, mpl_::false_) [with RhsT = RhsT; T0_ = boost::shared_ptr<int>; T1 = boost::detail::variant::void_; T2 = boost::detail::variant::void_; T3 = boost::detail::variant::void_; T4 = boost::detail::variant::void_; T5 = boost::detail::variant::void_; T6 = boost::detail::variant::void_; T7 = boost::detail::variant::void_; T8 = boost::detail::variant::void_; T9 = boost::detail::variant::void_; T10 = boost::detail::variant::void_; T11 = boost::detail::variant::void_; T12 = boost::detail::variant::void_; T13 = boost::detail::variant::void_; T14 = boost::detail::variant::void_; T15 = boost::detail::variant::void_; T16 = boost::detail::variant::void_; T17 = boost::detail::variant::void_; T18 = boost::detail::variant::void_; T19 = boost::detail::variant::void_]
/usr/local/include/boost/variant/variant.hpp:2033:14: note:   template argument deduction/substitution failed:
/usr/local/include/boost/variant/variant.hpp:2058:13: note:   cannot convert ‘nothrow_copy()’ (type ‘nothrow_copy {aka mpl_::bool_<true>}’) to type ‘mpl_::false_ {aka mpl_::bool_<false>}’
4

0 に答える 0