$ cat test.cpp template<typename X> struct junk { template<typename Y> static Y& y(); template<typename Y> char test(typeof(y<Y>().foo())*); static int const value=sizeof(test<X>(0)); }; int function() { int const v=junk<int>::value; };
$ g++ -c -v test.cpp Using built-in specs. Target: x86_64-unknown-linux-gnu Configured with: /home/rk/xdisw/base/gnutools/gcc-4.3.3/configure --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++ --enable-werror Thread model: posix gcc version 4.3.3 (GCC) COLLECT_GCC_OPTIONS='-c' '-v' '-shared-libgcc' '-mtune=generic' /usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.3.3/cc1plus -quiet -v -D_GNU_SOURCE test.cpp -quiet -dumpbase test.cpp -mtune=generic -auxbase test -version -o /tmp/ccn9FvNk.s ignoring nonexistent directory "/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.3.3/../../../../x86_64-unknown-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.3.3/../../../../include/c++/4.3.3 /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.3.3/../../../../include/c++/4.3.3/x86_64-unknown-linux-gnu /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.3.3/../../../../include/c++/4.3.3/backward /usr/local/include /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.3.3/include /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.3.3/include-fixed /usr/include End of search list. GNU C++ (GCC) version 4.3.3 (x86_64-unknown-linux-gnu) compiled by GNU C version 4.3.3, GMP version 4.2.4, MPFR version 2.3.2. GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: f44867537d1291d59450732603599474 test.cpp: In instantiation of 'const int junk<int>::value': test.cpp:7: instantiated from here test.cpp:4: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. $ uname -a Linux wata 2.6.18-92.1.22.el5 #1 SMP Tue Dec 16 11:57:43 EST 2008 x86_64 x86_64 x86_64 GNU/Linux -- Summary: Segmentation fault Product: gcc Version: 4.3.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: kononov at ftml dot net GCC build triplet: x86_64-unknown-linux-gnu GCC host triplet: x86_64-unknown-linux-gnu GCC target triplet: x86_64-unknown-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39070