Boost logo

Boost Users :

Subject: Re: [Boost-users] [utility] addressof issue with classes havingtemplated conversion operators
From: Peter Dimov (pdimov_at_[hidden])
Date: 2009-03-20 12:13:07


Gevorg Voskanyan:
> 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?

Yes, this is a regression. Unfortunately, my attempts so far to fix it have
been alternately thwarted by MSVC's ability to convert function pointers to
void* and by the inclination of your convertible class to convert to
anything. I'll keep trying.


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