https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70635
Bug ID: 70635 Summary: ICE on (and rejects) valid code on x86_64-linux-gnu: Segmentation fault (program cc1plus) Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: su at cs dot ucdavis.edu Target Milestone: --- The following code causes an ICE when compiled with the current GCC trunk (and 4.9.x and later) on x86_64-linux-gnu in both 32-bit and 64-bit modes. The code does not cause an ICE for 4.8.x (and earlier), but is rejected. It looks valid and is accepted by clang. $ g++-trunk -v Using built-in specs. COLLECT_GCC=g++-trunk COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/6.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc-source-trunk/configure --enable-languages=c,c++,lto --prefix=/usr/local/gcc-trunk --disable-bootstrap Thread model: posix gcc version 6.0.0 20160411 (experimental) [trunk revision 234874] (GCC) $ $ g++-trunk -c small.cpp small.cpp:11:37: error: declaration of ‘typedef typename A<typename A<T>::B::type>::type A<T>::B::type’ -fpermissive] typedef typename A < type >::type type; ^~~~ small.cpp:5:28: error: changes meaning of ‘type’ from ‘typedef typename A<T>::B::type A<T>::type’ [-fpermissive] typedef typename B::type type; ^~~~ g++-trunk: internal compiler error: Segmentation fault (program cc1plus) Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. $ $ g++-4.8 -c small.cpp small.cpp:11:37: error: declaration of ‘typedef typename A<typename A<T>::B::type>::type A<T>::B::type’ [-fpermissive] typedef typename A < type >::type type; ^ small.cpp:5:28: error: changes meaning of ‘type’ from ‘typedef typename A<T>::B::type A<T>::type’ [-fpermissive] typedef typename B::type type; ^ $ $ clang++-trunk -c small.cpp -Weverything $ ------------------------------------------------ template < typename T > struct A { struct B; typedef typename B::type type; }; template < typename T > struct A < T >::B { typedef typename A < type >::type type; type Foo (); }; template < typename T > typename A < T >::B::type A < T >::B::Foo () { return 0; }