Patch: New implementation of -Wstrict-aliasing

Silvius Rus
Thu Feb 1 20:25:00 GMT 2007

On 01 Feb 2007 05:01:00 -0600, Gabriel Dos Reis <> wrote:
> Do you have some data about the relative cost (in terms of
> compiler-time) of level 2 vs level 3?  This is for decidiing which
> should be the default.

Hi Gaby,

The compile time difference from level 2 vs level 3 appears to be
insignificant at both -O0 and -O2 (see timing results below).  The
only potential serious source of overhead would be the points-to based
analysis, which only runs at -O2 or higher.  However, the overhead
turns out to be very low because the points-to information is highy
preprocessed by pass_may_alias.  The warning pass looks only at
pointers that are both aliased and known to be dereferenced in the
current function.  Also, level 2 may end up looking at more conversion
expressions because it does not check whether pointers are referenced,
so in some cases level 2 could actually be slightly more expensive
than level 3.

Let me know if you agree with default = level 3.

Is there a standard way to measure GCC's compilation overhead?  Here
are the timing results from building GMP on i686 (all times in

-O0 -fstrict-aliasing:
-O0 -fstrict-aliasing -Wstrict-aliasing=2:
-O0 -fstrict-aliasing -Wstrict-aliasing=3:

-O2 -fstrict-aliasing:
-O2 -fstrict-aliasing -Wstrict-aliasing=2:
-O2 -fstrict-aliasing -Wstrict-aliasing=3:

> Many thanks for doing this.
> -- Gaby

I am happy to help.

More information about the Gcc-patches mailing list