Optimized code fails to assign struct member
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
gcc-4.7 (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
Hi,
I've upgraded to Ubuntu 12.10 on Intel i7 2600 (64-bit version) and -as a developer- compiled SWI-Prolog using
the standard gcc 4.7 compiler. All seems to work, except for the `semweb' package. It works with compiled
without optimization, but fails at -O2.
After a bit searching with gdb, it appears that a structure assignment is simply omitted. I've forced it to work
by adding a dummy function and call this using the structure field as argument.
Not sure how to report this as building the whole system is a bit work. So, I'll first provide a pointer to the
work-around commit. This can be found at the address below. The first change is irrelevant, but indicates
the location of the missing assignment.
The dummy function itself is simply
#if __GNUC__ == 4 && __GNUC_MINOR__ == 7
void
gcc_47_dummy(void *ptr)
{ static void *p;
if ( p != ptr )
p = ptr;
}
#endif
Of course, I know that adding dummy calls can make the difference without the compiler being at fault, but
- I can see in gdb that the assignment is not done without the hack. Of course, I also know that gdb
sometimes does weird things with optimized code. Adding a print statement fixes the problem ...
The failed assignment does however explain subsequent (wrong) behaviour.
I'll leave it here, providing further details as deemed necessary on request.
Thanks --- Jan
Status changed to 'Confirmed' because the bug affects multiple users.