Performing constant calculations depending on template parameters causes an internal compiler error. Compile the code below with g++ -c foo.cpp to reproduce.
template <class T> struct A { static const unsigned a = (sizeof(T[3])-sizeof(T[2])); unsigned foo(unsigned b) { return a*b; } }; I do not get the ICE when compiling the code with my distribution compiler (Ubuntu Dapper gcc 4.0.3), only with my self-compiled 4.0.3 that has checking enabled. I only noticed this by accident when I build a checking compiler to hunt a different gcc bug. My configuration options as shown by g++ -v (mostly copied from the distribution compiler): ../configure --enable-languages=c,c++ --prefix=/home/tneumann/gcc4 --enable-shared --with-system-zlib --without-included-gettext --enable-threads=posix --enable-nls --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --disable-werror --enable-checking --disable-multilib x86_64-linux-gnu -- Summary: ICE on dependent const folding Product: gcc Version: 4.0.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: tneumann at pi3 dot informatik dot uni-mannheim dot de GCC host triplet: x86_64-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27465