Boost logo

Boost Users :

Subject: [Boost-users] [utility] addressof issue with classes having templated conversion operators
From: Gevorg Voskanyan (v_gevorg_at_[hidden])
Date: 2009-03-20 07:35:04


Hi folks,

I've came across a problem with addressof() when the argument is of a class type with a template conversion operator. A minimal test case reproducing the issue is attached.
Using boost 1.38, the example fails to compile under gcc 4.2.2, with the following error:

../../../../vendor/boost/boost_1_38_0/boost/utility/addressof.hpp: In function 'T* boost::addressof(T&) [with T = convertible]':
addressof_conversion.cpp:17: instantiated from here
boost/boost_1_38_0/boost/utility/addressof.hpp:42: error: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
../../../../vendor/boost/boost_1_38_0/boost/utility/addressof.hpp:26: note: candidate 1: static T* boost::detail::addressof_impl<T>::f(T&, long int) [with T = convertible]
../../../../vendor/boost/boost_1_38_0/boost/utility/addressof.hpp:32: note: candidate 2: static T* boost::detail::addressof_impl<T>::f(T*, int) [with T = convertible]

AFAICT gcc is right complaining here, according to 13.3.3

The same example compiles OK with boost 1.33.1, and the changeset that causes the difference seems to be this one:
https://svn.boost.org/trac/boost/changeset/44705

Can this be considered a regression?
How should this issue be addressed?

Thanks,
Gevorg

      



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net