Re: compile with gcc option -O0 or -O

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



David Brown <david@xxxxxxxxxxxxxxx> 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.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux