[Bug c++/42539] New: C++0x: I tried to implement is_explicitly_convertible, but all I got was this lousy ICE
d dot frey at gmx dot de
gcc-bugzilla@gcc.gnu.org
Tue Dec 29 14:28:00 GMT 2009
I tried to implement C++0x's std::is_explicitly_convertible, but decltype
crashes on my code with an internal compiler error. The code is:
#include <type_traits>
namespace my_std
{
namespace impl
{
template< typename T > T make();
template< typename From, typename To >
decltype( From( make< To >() ), make< std::true_type >() ) select();
template< typename From, typename To >
std::false_type select();
}
template< typename From, typename To >
struct is_explicitly_convertible
: std::is_same< decltype( impl::select< From, To > ), std::true_type >
{
};
}
struct X
{
X( double& );
explicit X( int& );
};
#define STATIC_ASSERT( X ) static_assert( X, #X )
int main()
{
STATIC_ASSERT(( my_std::is_explicitly_convertible< double&, X >::value ));
STATIC_ASSERT(( my_std::is_explicitly_convertible< int&, X >::value ));
STATIC_ASSERT(( !my_std::is_explicitly_convertible< void*, X >::value ));
}
Tested on GCC 4.3.3 (Ubuntu 9.04) and 4.4.2 (self-compiled), error messages:
frey@viasko::~/work/test/is_explicitly_convertible$ g++ --version
g++ (Ubuntu 4.3.3-5ubuntu4) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
frey@viasko::~/work/test/is_explicitly_convertible$ g++ -std=c++0x t.cc -o t
t.cc: In instantiation of Âpwd::is_explicitly_convertible<double&, X>Â:
t.cc:35: instantiated from here
t.cc:21: internal compiler error: in finish_decltype_type, at
cp/semantics.c:4231
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.3/README.Bugs> for instructions.
frey@viasko:1:~/work/test/is_explicitly_convertible$ . ~/work/use_gcc.sh
frey@viasko::~/work/test/is_explicitly_convertible$ g++ --version
g++ (GCC) 4.4.2
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
frey@viasko::~/work/test/is_explicitly_convertible$ g++ -std=c++0x t.cc -o t
t.cc: In instantiation of Âpwd::is_explicitly_convertible<double&, X>Â:
t.cc:35: instantiated from here
t.cc:21: internal compiler error: in finish_decltype_type, at
cp/semantics.c:4689
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
frey@viasko:1:~/work/test/is_explicitly_convertible$
Regards, Daniel
--
Summary: C++0x: I tried to implement is_explicitly_convertible,
but all I got was this lousy ICE
Product: gcc
Version: 4.4.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: d dot frey at gmx dot de
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42539
More information about the Gcc-bugs
mailing list