From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12085 invoked by alias); 29 Dec 2009 14:28:10 -0000 Received: (qmail 12065 invoked by uid 48); 29 Dec 2009 14:27:59 -0000 Date: Tue, 29 Dec 2009 14:28:00 -0000 Subject: [Bug c++/42539] New: C++0x: I tried to implement is_explicitly_convertible, but all I got was this lousy ICE X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "d dot frey at gmx dot de" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2009-12/txt/msg02634.txt.bz2 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 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’: 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 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’: 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 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