The following crashes g++: enum Channel { A, enumMin = A, B, enumMax = B };
template < typename T > struct enum_traits { static T const first = T::enumMin; }; template < typename Enum > struct cb_handler { typedef Enum channel_type; typedef void(*callback_function)(void); static channel_type const min_channel = enum_traits<channel_type>::first; template < channel_type channel > static void forward ( void ) {} public: static callback_function bad ( void ) { return( forward<min_channel> ); } }; // cb_handler; typedef cb_handler<Channel> handler; int main ( void ) { handler::bad(); } My settings: > /added/pkg/gcc-4.0.1/usr/bin/g++ -v Using built-in specs. Target: i686-pc-linux-gnu Configured with: ../gcc-4.0.1/configure --prefix=/added/pkg/gcc-4.0.1/usr Thread model: posix gcc version 4.0.1 -- Summary: Internal error: Segmentation fault (program cc1plus) Product: gcc Version: 4.0.1 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jkherciueh at gmx dot net http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24448