[g++] -O produces incorrect code

Christoph Bartoschek bartoschek@gmx.de
Sun Oct 7 19:54:00 GMT 2007


Am Sonntag 07 Oktober 2007 schrieb Martin Schröder:

> We have tracked it down to one source file; if it is compiled with -O,
> we get the above error and valgrind screams:

We already had several occurences of such a problem and each time it was a 
fault in our code and not in gcc.

Generally one cannot help without the code. Where to get it? But one hint:

Use #include <valgrind/memcheck.h> and check each value in the line with

VALGRIND_CHECK_VALUE_IS_DEFINED(variable)

Do this with each subexpression and follow the stack up to the declaration of 
the offending variable. 

One particularly nasty problem was once a bitfield with only 31 defined bits 
but all bits were used in a comparison. Only in compiled code 32. bit was 
left uninitialized.

Greetings
Christoph



More information about the Gcc-help mailing list