Hi,
the newest GPC release (with 3.2.1 backend) crashes on the program below:
program foo;
var v : 0 .. maxint; d : integer;
begin v := (v mod d) * 32768; end.
[pas]% gpc -v Reading specs from /usr/local/lib/gcc-lib/i586-pc-linux-gnu/3.2.1/specs Configured with: ../gcc-3.2.1/configure --enable-languages=pascal --disable-nls Thread model: posix gpc version 20030209, based on gcc-3.2.1 [pas]% gpc crash1.pas crash1.pas: In main program: crash1.pas:8: Internal compiler error in copy_to_mode_reg, at explow.c:725 Please submit a full bug report, with preprocessed source if appropriate. See URL:http://www.gnu-pascal.de/todo.html for instructions.
I also encountered some segfaults. Unfortunately I wasn't able to reduce the problem to a simple test case, because it manifests only during garbage collection (which doesn't occur at all on short input files, and the trouble might arose long before the actual crash anyway). I'll try to rebuild the compiler with GC checking enabled to see what happens.
[pas]% gpc -O2 tex.p -Q texinthandler readtcxfile parsecnum blanks initialize println printrealch printchar print printnl printesc printthedigs printint printcs sprintcs printfilename printsize printwritewhatsit jumpout error fatalerror overflow confusion aopenin aopenout bopenin wopenin wopenout inputln initterminal {GC 5353k -> tex.p: In function `initterminal': tex.p:539: internal error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See URL:http://www.gnu-pascal.de/todo.html for instructions.
[pas]% gdb /usr/local/lib/gcc-lib/i586-pc-linux-gnu/3.2.1/gpc1 GNU gdb Red Hat Linux (5.1.90CVS-5) Copyright 2002 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-redhat-linux"... (gdb) attach 12354 Attaching to program: /usr/local/lib/gcc-lib/i586-pc-linux-gnu/3.2.1/gpc1, process 12354 Reading symbols from /lib/libc.so.6...done. Loaded symbols for /lib/libc.so.6 Reading symbols from /lib/ld-linux.so.2...done. Loaded symbols for /lib/ld-linux.so.2 insn_variable_length_p (insn=0x401b3860) at insn-attrtab.c:48 48 return 0; (gdb) cont Continuing.
Program received signal SIGCONT, Continued. insn_variable_length_p (insn=0x401b3860) at insn-attrtab.c:48 48 return 0; (gdb) Continuing.
Program received signal SIGSEGV, Segmentation fault. 0x0822d4e1 in ggc_set_mark (p=0x25701d8) at ../../gcc-3.2.1/gcc/ggc-page.c:439 439 return base[L1][L2]; (gdb) bt #0 0x0822d4e1 in ggc_set_mark (p=0x25701d8) at ../../gcc-3.2.1/gcc/ggc-page.c:439 #1 0x0813b21b in ggc_mark_tree_ptr (elt=0xbffff7f8) at ../../gcc-3.2.1/gcc/ggc-common.c:628 #2 0x0813a137 in ggc_mark_roots () at ../../gcc-3.2.1/gcc/ggc-common.c:256 #3 0x0822da21 in ggc_collect () at ../../gcc-3.2.1/gcc/ggc-page.c:1429 #4 0x080cbbdb in rest_of_compilation (decl=0x4050ebd0) at ../../gcc-3.2.1/gcc/toplev.c:3385 #5 0x08054627 in finish_function (nested=0) at ../../gcc-3.2.1/gcc/p/gpc-decl.c:5029 #6 0x0807128e in main_yyparse () at parse.y:2921 #7 0x080ca159 in compile_file () at ../../gcc-3.2.1/gcc/toplev.c:2124 #8 0x080ce25b in do_compile () at ../../gcc-3.2.1/gcc/toplev.c:5218 #9 0x080ce2b9 in toplev_main (argc=8, argv=0xbffff944) at ../../gcc-3.2.1/gcc/toplev.c:5250 #10 0x4003c0c4 in __libc_start_main () from /lib/libc.so.6
Further playing with the debugger revealed that base[L1] was a NULL pointer.
Emil