The code below generates an ICE with g++ 3.3 (debian stable), g++ 3.4 (debian testing): ------------------------------------------------ [pollindd] ~ >g++-3.3 -c ice-typeid.cc ice-typeid.cc: In function `int bug5(BaseB*)': ice-typeid.cc:43: internal compiler error: in expand_expr, at expr.c:8833 Please submit a full bug ... [pollindd] ~ >g++-3.4 -c ice-typeid.cc ice-typeid.cc: In function `int bug5(BaseB*)': ice-typeid.cc:43: internal compiler error: in expand_expr_real, at expr.c:8469 Please submit a full bug report... ------------------------------------------------ It works well with g++ 2.95.4 (debian). Maybe related to bug #25357. ------------------------------------------------ [pollindd] ~ >g++-3.4 -v Reading specs from /usr/lib/gcc/i486-linux/3.4.4/specs Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --libexecdir=/usr/lib --with-gxx-include-dir=/usr/include/c++/3.4 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --program-suffix=-3.4 --enable-__cxa_atexit --enable-libstdcxx-allocator=mt --enable-clocale=gnu --enable-libstdcxx-debug --enable-java-gc=boehm --enable-java-awt=gtk --disable-werror i486-linux Thread model: posix gcc version 3.4.4 20050314 (prerelease) (Debian 3.4.3-13) [pollindd] ~ >g++-3.3 -v Reading specs from /usr/lib/gcc-lib/i486-linux/3.3.6/specs Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --enable-__cxa_atexit --with-system-zlib --enable-nls --without-included-gettext --enable-clocale=gnu --enable-debug --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc i486-linux Thread model: posix gcc version 3.3.6 (Debian 1:3.3.6-5) ------------------------------------------------ Code follows. Command line: g++-3.x -c ice-typeid.cc Optimisation flag seems to have no impact (same problem with -O3). Likewise for -Wall. It works on more complicated code (?!)... but it's hard to see where the fix is introduced. ------------------------------------------------ #include <typeinfo> class BaseB { public: virtual ~BaseB() {} }; #if BUG == 1 const char* bug1(BaseB const* o) { return typeid(typeid(*o)).name(); } #elif BUG == 2 const std::type_info & bug2(BaseB const* o) { return typeid(typeid(*o)); } #elif BUG == 3 const char* bug3(BaseB * o) { return typeid(typeid(*o)).name(); } #elif BUG == 4 const std::type_info & bug4(BaseB * o) { return typeid(typeid(*o)); } #else int bug5(BaseB * o) { int i; return (typeid(typeid(*o)) == typeid(i)); } #endif ------------------------------------------------
Created attachment 10907 [details] Code leading to ICE Compile it with -DBUG=xyz to activate bug xyz
Created attachment 10908 [details] Preprocessor output (gcc 3.4.4)
*** This bug has been marked as a duplicate of 26417 ***