Boost logo

Boost :

From: John Maddock (john_at_[hidden])
Date: 2006-04-14 06:13:03

> Hello,
> In a post from yesterday (see,
> Alexei Alexandrov found a rather serious problem with
> is_convertible in at least MSVC 7.1 and Intel 9.0, namely
> that is_convertible<From,To> fails to compile when
>> From is non-copyable, emitting an error message like this:
> boost/boost/type_traits/is_convertible.hpp(254): error:
> class "XXX" has no suitable copy constructor
> ...
> where XXX is the From argument. Needless to say, some
> fix for this issue would be most welcome. I'm sorry
> I cannot provide any more help than a mere report
> of the problem.
> Thank you,

Using the trivial code below I'm *unable* to reproduce this: it's compiles
cleanly with all the compilers I've tried (including Intel 9 and VC7.1).

However.... there is a long history of is_convertible doing strange things
under very specific circumstances with VC7.1 (and of course Intel emulate
VC's bugs).

Indeed the VC-specific implementation relies on undefined behaviour: passing
UDT's through a function with elipsis, and it's this that appears to be
causing the problem in this case. There are alternative implementations of
is_convertible - almost one per compiler in fact, which shows how much
trouble it's caused in the past - that do not rely on this undefined
behaviour, and do not pass UDT's through elipsis, and so should not have
this problem. Unfortunately these implementations could not be used with
VC++ because even though they pass all our type-traits regression tests,
they cause strange and unexplained failures deep within certain
instantiation contexts. Sound familiar?

Anyway, trivial test case follows,


#include <boost/type_traits.hpp>
#include <boost/noncopyable.hpp>

class bar : private boost::noncopyable

template <bool b>
class foo
static const bool value = b;

typedef foo< ::boost::is_convertible<bar, int>::value> foo_t;

const bool b = foo_t::value;

Boost list run by bdawes at, gregod at, cpdaniel at, john at