[type_traits] is_convertible<noncopyable,To> crashes

Hello, In a post from yesterday (see http://tinyurl.com/hzk5w), 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 BOOST_STATIC_CONSTANT(bool, value = ... 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, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

"JOAQUIN LOPEZ MU?Z" <joaquin@tid.es> writes:
Hello,
In a post from yesterday (see http://tinyurl.com/hzk5w), 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 BOOST_STATIC_CONSTANT(bool, value = ...
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.
I don't think this is a solvable problem, unless there's something hiding in the implementation of is_base_and_derived that can be leveraged (see the comment in that header for more info -- I can't understand what's being said there due to the use of the identifier 'C' without any introduction). The basic problem is what's required in the implementation of is_convertible in order to work around VC7.1 bugs (Intel Windows emulates the same bugs). -- Dave Abrahams Boost Consulting www.boost-consulting.com

David Abrahams <dave <at> boost-consulting.com> writes:
I don't think this is a solvable problem, unless there's something hiding in the implementation of is_base_and_derived that can be leveraged (see the comment in that header for more info -- I can't understand what's being said there due to the use of the identifier 'C' without any introduction). The basic problem is what's required in the implementation of is_convertible in order to work around VC7.1 bugs (Intel Windows emulates the same bugs).
It don't think it's VC/Intel specific problem. GCC 3.4.4 also refuses to compile this code: #include <boost/type_traits.hpp> #include <boost/noncopyable.hpp> class C : public boost::noncopyable { }; int main() { bool br = boost::is_convertible<C, C>::value; return static_cast<int>(br); }

JOAQUIN LOPEZ MU?Z wrote:
Hello,
In a post from yesterday (see http://tinyurl.com/hzk5w), 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 BOOST_STATIC_CONSTANT(bool, value = ...
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, John. #include <boost/type_traits.hpp> #include <boost/noncopyable.hpp> class bar : private boost::noncopyable { }; template <bool b> class foo { public: static const bool value = b; }; typedef foo< ::boost::is_convertible<bar, int>::value> foo_t; const bool b = foo_t::value;

In a post from yesterday (see http://tinyurl.com/hzk5w), 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:
Wait a second, I've just looked at the original error messages, and the test case is very specific, it fails for: is_convertible<const noncopyable, const noncopyable> That is known not to work, *and will never work*, there is no way we can define a trait that detects whether a type is copy-constructable or not. In other words the From and To parameters must be different types. Likewise is_convertible<From, To> will fail if To has a private constructor taking a From as argument. Sorry but it's an inherent limitation of the trait implemented without core-language support. John.
participants (4)
-
Alexei Alexandrov
-
David Abrahams
-
JOAQUIN LOPEZ MU?Z
-
John Maddock