compile with gcc option -O0 or -O
Miles Bader
miles@gnu.org
Fri Sep 16 07:54:00 GMT 2011
David Brown <david@westcontrol.com> writes:
>>> but one weird problem is that the following codes compiled with option -O0
>>
>> You need to show us a small complete self-contained example.
>>
>> Normally a program which works at -O0 and fails at -O1 has an
>> uninitialized variable somewhere.
>
> Another common cause is aliasing - using pointer casts to access the
> same data in different ways.
>
> And (especially if this is embedded programming), also check for missing
> "volatile" qualifiers.
>
> Compile your code with lots of warnings - that will help spot
> mistakes. The flags I often use are:
>
> -Wall
> -Wextra
> -Winit-self
> -Wmissing-include-dirs
...
... but be a bit wary of any warning option which isn't included in
-Wall or -Wextra -- they're usually omitted for a reason (typically
because they yield tons of false positives on reasonable code).
-Miles
--
Conservative, n. A statesman enamored of existing evils, as opposed to a
Liberal, who wants to replace them with new ones.
More information about the Gcc-help
mailing list