[Bug target/26511] Using -O3, doesn't assign in a pointer to a global structure

wielemak at science dot uva dot nl gcc-bugzilla@gcc.gnu.org
Thu Mar 2 09:24:00 GMT 2006



------- Comment #3 from wielemak at science dot uva dot nl  2006-03-02 09:24 -------
Andrew,

If you think this is a real and still present bug I could try to add a
little main() to the file and turn the file into a stand-alone program.
I guess it is pretty likely it depends on nasty details in the structure
definitions and it will be a lot of work to cut down the headers and
still be able to compile the program and reproduce the bug.

If you simply want to reproduce, fetch pl-5.6.6.tar.gz from
http://gollem.science.uva.nl/cgi-bin/nph-download/SWI-Prolog/pl-5.6.6.tar.gz
Unpack, goto pl-5.6.6/src, type ./configure, add -g to COFLAGS in
Makefile, make (few warnings, these are fixed already but do not affect
this problem), abort Prolog which will be crashing in a loop using ^\.
Now 

gdb pl
(gdb) break initPrologThreads
(gdb) run
(gdb) finish
(gdb) print *info

And you see the problem. The nasty thing is that if you add a
print-statement reading the info->pl_tid, it is compiled correctly. It
gives the impression that somehow gcc thinks the value is never used and
it thus can ignore the assignment. As the structure is in global memory
(part of the threads[] array) and it *is* used, this is of course
completely wrong.

   Cheers --- Jan


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26511



More information about the Gcc-bugs mailing list