Starting at least as earily as 2004-10-20, GCC will miscompile libcpp/charset.c, causing the built GCC to ICE when parsing a wide character literal.
This causes bootstrap to fail while attempting to compile a libjava source file that uses wide character literals. The only work-around that I have found so far is removing the wide character literal, or recompiling libcpp/charset.c without -O2. Any wide character usage in a file processed by the miscompiled compiler triggers this bug, such as: > void f() { > L'c'; > } I have no idea, though, how to minimize a testcase from GCC for the actual bug. Presently, I am testing for it by compiling cc1.exe, using it to re-compile libcpp/charset.o, re-linking cc1.exe with the new charset.o, and then attempting to compile the above testcase. (Presently, if GCC is built using 3.4.2, this problem doesn't show up, as libcpp is built by the host compiler, not by built compiler. Is this also a bug?) i686-pc-mingw32 Windows XP SP2 Professional Pentium 4 256MB binutils 2.15.94 20041023 mingwrt mainline 20041023 msvcrt 7.0.2600.2180 w32api mainline 20041023 libiconv 1.9.1 gmp 4.1.4 mpfr 2.0.3 GNU Make 3.80 expect 5.26 tcl 8.4 dejagnu 1.4.2.x host gcc 4.0.0 20041013 (experimental) host binutils 2.15.93 20041019 Misc tools and environment from Cygwin Current Fri Oct 22 01:50:41 2004 ln with softlinks disabled $ ./xgcc.exe -v Using built-in specs. Configured with: ../../src/cvs/head/gcc/configure --enable-languages=ada,c,c++,f95,java,objc --with-dwarf2 --enable-libmudflap --enable-libgcj --with-win32-nlsapi=unicows --enable-libstdcxx-allocator=mt --enable-libstdcxx-debug --prefix=/aaronwl/cs/env/mingw-head-head-head-20041023 --with-included-gettext --with-libiconv-prefix=/aaronwl/cs/internat/iconv/install --with-gmp=/aaronwl/cs/env/mingw-head-head-head-20041023 --with-mpfr=/aaronwl/cs/env/mingw-head-head-head-20041023 Thread model: win32 gcc version 4.0.0 20041023 (experimental) if /bin/sh ./libtool --mode=compile /aaronwl/cs/compilers/gcc/build/mingw-head/gcc/xgcc -shared-libgcc -B/aaronwl/cs/compilers/gcc/build/mingw-head/gcc/ -nostdinc++ -L/aaronwl/cs/compilers/gcc/build/mingw-head/i686-pc-mingw32/libstdc++-v3/src -L/aaronwl/cs/compilers/gcc/build/mingw-head/i686-pc-mingw32/libstdc++-v3/src/.libs -B/aaronwl/cs/env/mingw-head-head-head-20041023/i686-pc-mingw32/bin/ -B/aaronwl/cs/env/mingw-head-head-head-20041023/i686-pc-mingw32/lib/ -isystem /aaronwl/cs/env/mingw-head-head-head-20041023/i686-pc-mingw32/include -isystem /aaronwl/cs/env/mingw-head-head-head-20041023/i686-pc-mingw32/sys-include -DHAVE_CONFIG_H -I. -I../../../../src/cvs/head/gcc/libjava -I./include -I./gcj -I../../../../src/cvs/head/gcc/libjava -Iinclude -I../../../../src/cvs/head/gcc/libjava/include -I../../../../src/cvs/head/gcc/libjava/../boehm-gc/include -I../boehm-gc/include -I../../../../src/cvs/head/gcc/libjava/libltdl -I../../../../src/cvs/head/gcc/libjava/libltdl -I../../../../src/cvs/head/gcc/libjava/.././libjava/../gcc -I../../../../src/cvs/head/gcc/libjava/../zlib -I../../../../src/cvs/head/gcc/libjava/../libffi/include -I../libffi/include -O2 -g -O2 -fno-rtti -fnon-call-exceptions -fdollars-in-identifiers -Wswitch-enum -D_FILE_OFFSET_BITS=64 -ffloat-store -fno-omit-frame-pointer -Wextra -Wall -D_GNU_SOURCE -DPREFIX="\"/aaronwl/cs/env/mingw-head-head-head-20041023\"" -DLIBDIR="\"/aaronwl/cs/env/mingw-head-head-head-20041023/lib\"" -DBOOT_CLASS_PATH="\"/aaronwl/cs/env/mingw-head-head-head-20041023/share/java/libgcj-4.0.0.jar\"" -DJAVA_EXT_DIRS="\"/aaronwl/cs/env/mingw-head-head-head-20041023/share/java/ext\"" -g -O2 -MT java/io/natFile.lo -MD -MP -MF "$depbase.Tpo" -c -o java/io/natFile.lo java/io/natFile.cc; \ then mv -f "$depbase.Tpo" "$depbase.Plo"; else rm -f "$depbase.Tpo"; exit 1; fi /aaronwl/cs/compilers/gcc/build/mingw-head/gcc/xgcc -shared-libgcc -B/aaronwl/cs/compilers/gcc/build/mingw-head/gcc/ -nostdinc++ -L/aaronwl/cs/compilers/gcc/build/mingw-head/i686-pc-mingw32/libstdc++-v3/src -L/aaronwl/cs/compilers/gcc/build/mingw-head/i686-pc-mingw32/libstdc++-v3/src/.libs -B/aaronwl/cs/env/mingw-head-head-head-20041023/i686-pc-mingw32/bin/ -B/aaronwl/cs/env/mingw-head-head-head-20041023/i686-pc-mingw32/lib/ -isystem /aaronwl/cs/env/mingw-head-head-head-20041023/i686-pc-mingw32/include -isystem /aaronwl/cs/env/mingw-head-head-head-20041023/i686-pc-mingw32/sys-include -DHAVE_CONFIG_H -I. -I../../../../src/cvs/head/gcc/libjava -I./include -I./gcj -I../../../../src/cvs/head/gcc/libjava -Iinclude -I../../../../src/cvs/head/gcc/libjava/include -I../../../../src/cvs/head/gcc/libjava/../boehm-gc/include -I../boehm-gc/include -I../../../../src/cvs/head/gcc/libjava/libltdl -I../../../../src/cvs/head/gcc/libjava/libltdl -I../../../../src/cvs/head/gcc/libjava/.././libjava/../gcc -I../../../../src/cvs/head/gcc/libjava/../zlib -I../../../../src/cvs/head/gcc/libjava/../libffi/include -I../libffi/include -O2 -g -O2 -fno-rtti -fnon-call-exceptions -fdollars-in-identifiers -Wswitch-enum -D_FILE_OFFSET_BITS=64 -ffloat-store -fno-omit-frame-pointer -Wextra -Wall -D_GNU_SOURCE -DPREFIX=\"/aaronwl/cs/env/mingw-head-head-head-20041023\" -DLIBDIR=\"/aaronwl/cs/env/mingw-head-head-head-20041023/lib\" -DBOOT_CLASS_PATH=\"/aaronwl/cs/env/mingw-head-head-head-20041023/share/java/libgcj-4.0.0.jar\" -DJAVA_EXT_DIRS=\"/aaronwl/cs/env/mingw-head-head-head-20041023/share/java/ext\" -g -O2 -MT java/io/natFile.lo -MD -MP -MF java/io/.deps/natFile.Tpo -c java/io/natFile.cc -o java/io/natFile.o In file included from ./include/java-gc.h:29, from ../../../../src/cvs/head/gcc/libjava/include/jvm.h:25, from ./include/platform.h:33, from java/io/natFile.cc:12: ../boehm-gc/include/gc_config.h:113:1: warning: "PACKAGE_NAME" redefined In file included from java/io/natFile.cc:11: ./include/config.h:399:1: warning: this is the location of the previous definition In file included from ./include/java-gc.h:29, from ../../../../src/cvs/head/gcc/libjava/include/jvm.h:25, from ./include/platform.h:33, from java/io/natFile.cc:12: ../boehm-gc/include/gc_config.h:116:1: warning: "PACKAGE_STRING" redefined In file included from java/io/natFile.cc:11: ./include/config.h:402:1: warning: this is the location of the previous definition In file included from ./include/java-gc.h:29, from ../../../../src/cvs/head/gcc/libjava/include/jvm.h:25, from ./include/platform.h:33, from java/io/natFile.cc:12: ../boehm-gc/include/gc_config.h:119:1: warning: "PACKAGE_TARNAME" redefined In file included from java/io/natFile.cc:11: ./include/config.h:405:1: warning: this is the location of the previous definition In file included from ./include/java-gc.h:29, from ../../../../src/cvs/head/gcc/libjava/include/jvm.h:25, from ./include/platform.h:33, from java/io/natFile.cc:12: ../boehm-gc/include/gc_config.h:122:1: warning: "PACKAGE_VERSION" redefined In file included from java/io/natFile.cc:11: ./include/config.h:408:1: warning: this is the location of the previous definition java/io/natFile.cc:170: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. make[3]: *** [java/io/natFile.lo] Error 1 Program received signal SIGSEGV, Segmentation fault. 0x00000000 in ?? () from (gdb) bt #0 0x00000000 in ?? () from #1 0x0092b892 in cpp_interpret_string (pfile=0x1791a00, from=0x1791c68, count=1, to=0x22fe34, wide=1 '\001') at ../../../src/cvs/head/gcc/libcpp/charset.c:1168 #2 0x0092c05c in cpp_interpret_charconst (pfile=0x1791a00, token=0x1791c60, pchars_seen=0x22fea4, unsignedp=0x22fea8) at ../../../src/cvs/head/gcc/libcpp/charset.c:1347 #3 0x0053cdad in c_lex_with_flags (value=0x1882054, cpp_flags=0x1882052 '¯' <repeats 200 times>...) at ../../../src/cvs/head/gcc/gcc/c-lex.c:800 #4 0x0049d11d in cp_lexer_get_preprocessor_token (lexer=Variable "lexer" is not available. ) at ../../../src/cvs/head/gcc/gcc/cp/parser.c:384 #5 0x004b374c in c_parse_file () at ../../../src/cvs/head/gcc/gcc/cp/parser.c:281 #6 0x00545245 in c_common_parse_file (set_yydebug=0) at ../../../src/cvs/head/gcc/gcc/c-opts.c:1095 #7 0x00666c20 in toplev_main (argc=0, argv=0x3d41f0) at ../../../src/cvs/head/gcc/gcc/toplev.c:986 #8 0x00401183 in __mingw_CRTStartup () at ../../../src/cvs/runtime/crt1.c:207 #9 0x00401208 in mainCRTStartup () at ../../../src/cvs/runtime/crt1.c:227 Due to optimization, GDB wasn't able to print any of the interesting-looking variables. -- Summary: [4.0 Regression] GCC miscompiles libcpp/charset.c Product: gcc Version: 4.0.0 Status: UNCONFIRMED Keywords: wrong-code, build Severity: critical Priority: P2 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: aaronavay62 at aaronwl dot com CC: gcc-bugs at gcc dot gnu dot org GCC target triplet: i686-pc-mingw32 OtherBugsDependingO 18107 nThis: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18139