http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54946
Bug #: 54946 Summary: ICE on template parameter from cast char-pointer in C++11 constexpr struct Classification: Unclassified Product: gcc Version: 4.7.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: bisq...@iki.fi The following C++11 code causes an ICE. template<conts char*s> static void testfunc(); constexpr struct testtype { const char* str; } test = { "abc"} ; void (*functionpointer)() = testfunc<(const char*) test.str>; Sample GCC commandline to invoke the error: g++ test1.cc -std=c++0x Error message on g++-4.7.1 (Debian 4.7.1-7 on x86_64) test1.cc:5:29: internal compiler error: in convert_nontype_argument, at cp/pt.c:5794 Error message on g++-4.6.3 (Debian 4.6.3-11 on x86_64): test1.cc:5:29: internal compiler error: in convert_nontype_argument, at cp/pt.c:5430 I do not know whether the code is valid. Things that do not affect the error: - Adding / removing "const" at any point or changing pointers into arrays at any point - Changing functionpointer into an array of function pointers - Any code generation related options (such as -m32 or optimization levels) Things that do hide the error: - Removing the (const char*) cast entirely - Changing the string pointers into integers - Removing the struct encapsulation from str (making it constexpr const char* str = "abc"; and removing "test." from the third line)