This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

-Wstrict-aliasing=2 does not warn about all problems


Hi Jim, the documentation for -Wstrict-aliasing=2 says:

    It warns about all code which might break the strict aliasing
    rules that the compiler is using for optimization.  This warning
    catches all cases, but it will also give a warning for some
    ambiguous cases that are safe.

However, there are a number of cases of aliasing which it does not
catch.  For example, see PR 23106.  In general, the warning is
disabled by casts through void* or char*.  Also, the warning only
applies to casts of the address of a variable.

In general, I think the risky code is when we see some ordering of
these three statements:
    p2 = (TYPE *) p1;
    *p2;
    *p1;
However, computing that is probably non-trivial.

Anyhow, I think we need to change the documentation for
-Wstrict-aliasing=2.  It warns about more possible problems than
-Wstrict-aliasing, but it does not warn about all possible problems.

Any thoughts?

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]