high priority: gcc generates weird code
QingLong
qinglong@Bolizm.ihep.su
Fri Mar 2 11:13:00 GMT 2001
Hello!
The program attached to this message been compiled by GCC
segfaults at line 65. This excerpt from gdb:
|
| Starting program: ./reverse
| 20 3-byte elements:
| .oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO
|
| Program received signal SIGSEGV, Segmentation fault.
| 0x8048840 in Queue_reverse_byte_order (the_buf=0x8049d00, the_size=3,
| the_nmemb=20, theVerbose=1, theDebug=1) at reverse.c:65
| 65 *j_tail_p = *j_head_p;
| (gdb) where
| #0 0x8048840 in Queue_reverse_byte_order (the_buf=0x8049d00, the_size=3,
| the_nmemb=20, theVerbose=1, theDebug=1) at reverse.c:65
| #1 0x804892c in main (argc=1, argv=0xbfffe184) at reverse.c:94
| #2 0x40031a4e in __libc_start_main (main=0x8048884 <main>, argc=1,
| argv=0xbfffe184, init=0x80485d0 <_init>, fini=0x8049b74 <_fini>,
| rtld_fini=0x4000c0c4 <_dl_fini>, stack_end=0xbfffe17c)
| at ../sysdeps/generic/libc-start.c:78
| (gdb) print j_head_p
| $1 = 0x8049d00 ".oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO"
| (gdb) print j_tail_p
| $2 = 0x8049d02 "O.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO"
| (gdb) print i_head_p
| $3 = 0x8049d00 ".oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO"
| (gdb) print i_tail_p
| $4 = 0x8049d03 ".oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO.oO"
| (gdb) print *j_tail_p
| $5 = 79 'O'
| (gdb) print *j_head_p
| $6 = 46 '.'
| (gdb) kill
| Kill the program being debugged? (y or n) y
| (gdb) quit
|
I've tried to compile it with (and without) -O, -O6,
tried gcc versions (output of `gcc -v'):
|
| Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
| gcc version 2.96 20000731 (Red Hat Linux 7.0)
+------------------------------------------------------------------
| Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.3/specs
| gcc version 2.95.3 20010125 (prerelease)
+------------------------------------------------------------------
| Reading specs from /usr/lib/gcc-lib/alpha-unknown-openbsd2.8/2.95.3/specs
| gcc version 2.95.3 19991030 (prerelease)
+------------------------------------------------------------------
| Reading specs from /usr/lib/gcc-lib/mipsel-unknown-openbsd2.7/2.95.3/specs
| gcc version 2.95.3 19991030 (prerelease)
+------------------------------------------------------------------
| Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/specs
| gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
+------------------------------------------------------------------
| Reading specs from /opt/egcs/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.60/specs
| gcc version egcs-2.91.60 19981201 (egcs-1.1.1 release)
+------------------------------------------------------------------
| Reading specs from /usr/lib/gcc-lib/mipsel-unknown-openbsd2.3/2.8.1/specs
| gcc version 2.8.1
+------------------------------------------------------------------
| Reading specs from /usr/local/lib/gcc-lib/vax-dec-ultrix4.3/2.8.1/specs
| gcc version 2.8.1
|
with absolutely the same result.
I believe that the code is correct as `gcc -Wall' issues no warnings,
as do cc's on ``OSF1 V5.0 1094 alpha'' and ``IRIX 6.2 06101030 IP22''
(failed to find out more version info on those compilers),
while the latter does produce correct binary that behaves quite as expected.
After trying varoius systems here, I've found out that actually
there are GCC installations that are able to handle the code:
|
| Reading specs from /usr/gnu/lib/gcc-lib/mips-sgi-irix5.3/2.7.2.2/specs
| gcc version 2.7.2.2
+------------------------------------------------------------------
| Reading specs from /usr/local/lib/gcc-lib/alpha-dec-osf4.0b/egcs-2.91.60/specs
| gcc version egcs-2.91.60 19981201 (egcs-1.1.1 release)
|
I think it's not worth submitting you separate reports for all those
buggy versions, so I just do it for one of them.
Please see mail attachments. If you need more info, please ask me.
Thank you.
QingLong.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: reverse.i.gz
Type: application/x-gzip
Size: 3888 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/20010302/1f9ba232/attachment.bin>
More information about the Gcc-bugs
mailing list