This is the mail archive of the gcc-patches@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]

Re: RFC: -Wstrict-aliasing extension


On Mon, 2004-03-08 at 13:24, Mark Mitchell wrote:
> I'm not crazy about the false positive.  I have a strong bias against 
> warnings with false positives, which I think comes from my background in 
> error-checking tools.  So, I guess I'm disinclined towards this patch.  
> But, not all that strongly.

It isn't possible for the compiler to exactly identify all casts that
will cause miscompilation with -fstrict-aliasing.  Or at least, there is
no reasonable way to do this.  Thus we have a choice between emitting
too few warnings or too many.  The current -Wstrict-aliasing code emits
too few.  This is nice from the standpoint that we can make -Wall
include it.

However, there is a real problem here for users trying to upgrade from
gcc-2.95 to gcc-3.x.  They find their code fails, and then they find
that there is no -W option that can help them, because -Wstrict-aliasing
emits too few warnings.  My proposed patch helps these users by emitting
the warnings they need in order to fix their code.  It also emits false
positives that the users have to ignore, but it is better to get a false
warning than to have the compiler silently miscompile your code.

> I'm also disinclined towards adding more warning options

I suggested -Wstrict-aliasing=2 as an alternative which I think helps
with the design issue.  This avoids adding a new option, and makes it
clearer what the relationship is with the existing -Wstrict-aliasing
option.  -Wstrict-aliasing=2 will emit more warnings than
-Wstrict-aliasing, including some that you may not want.
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com


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