Opened 12 years ago

Closed 9 years ago

#5487 closed Bugs (fixed)

Trying to get<nullptr_t> from a variant results in error with vs10

Reported by: dd0t@… Owned by: Peter Dimov
Milestone: To Be Determined Component: utility
Version: Boost 1.46.1 Severity: Problem
Keywords: nullptr_t variant addressof Cc: antoshkka@…

Description

Trying to retrieve a nullptr_t type object from a boost variant with get<std::nullptr_t> on vs 2010 sp1 results in a:

error C2666: 'boost::detail::addressof_impl<T>::f' : 2 overloads have similar conversions

error. The same code compiles fine on gcc 4.6.0.

See attached minimal sample.

Attachments (1)

nullptr_t_in_variant.cpp (141 bytes ) - added by dd0t@… 12 years ago.
Minimal example reproducing the problem

Download all attachments as: .zip

Change History (6)

by dd0t@…, 12 years ago

Attachment: nullptr_t_in_variant.cpp added

Minimal example reproducing the problem

comment:1 by Antony Polukhin, 9 years ago

Cc: antoshkka@… added
Component: variantutility
Owner: changed from ebf to No-Maintainer

Even a simpler example:

#include <boost/utility/addressof.hpp>

int main() {
    auto p = nullptr;
    boost::addressof(p);
}

Code above results gives the same error on MSVC11:

F:\boost_1_55_0\boost/utility/addressof.hpp(59): error C2666: 'boost::detail::addressof_impl<T>::f' : 2 overloads have similar conversions
1>          with
1>          [
1>              T=nullptr
1>          ]
1>          F:\boost_1_55_0\boost/utility/addressof.hpp(43): could be 'nullptr *boost::detail::addressof_impl<T>::f(T *,int)'
1>          with
1>          [
1>              T=nullptr
1>          ]
1>          F:\boost_1_55_0\boost/utility/addressof.hpp(37): or       'nullptr *boost::detail::addressof_impl<T>::f(T &,long)'
1>          with
1>          [
1>              T=nullptr
1>          ]
1>          while trying to match the argument list '(boost::detail::addr_impl_ref<T>, int)'
1>          with
1>          [
1>              T=nullptr
1>          ]
1>          main.cpp(5) : see reference to function template instantiation 'T *boost::addressof<nullptr>(T &)' being compiled
1>          with
1>          [
1>              T=nullptr
1>          ]

While GCC compiles successfully.

comment:2 by Marshall Clow, 9 years ago

Also fails on a (fairly recent) clang:

$ clang++ -std=c++11 -stdlib=libc++ -I /Sources/boost/SVN/release/ boost.cpp
In file included from boost.cpp:1:
/Sources/boost/SVN/release/boost/utility/addressof.hpp:59:12: error: call to 'f'
      is ambiguous
    return boost::detail::addressof_impl<T>::f( boost::detail::addr_impl...
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
boost.cpp:5:5: note: in instantiation of function template specialization
      'boost::addressof<nullptr_t>' requested here
    boost::addressof(p);
    ^
/Sources/boost/SVN/release/boost/utility/addressof.hpp:37:23: note: candidate
      function
    static inline T * f( T & v, long )
                      ^
/Sources/boost/SVN/release/boost/utility/addressof.hpp:43:23: note: candidate
      function
    static inline T * f( T * v, int )
                      ^
1 error generated.

comment:3 by Marshall Clow, 9 years ago

Owner: changed from No-Maintainer to Peter Dimov

comment:5 by Peter Dimov, 9 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.