Related articles |
---|
ANSI alias rules checker in GCC, other optimizing compilers andreybokhanko@gmail.com (2007-01-16) |
Re: ANSI alias rules checker in GCC, other optimizing compilers ian@airs.com (Ian Lance Taylor) (2007-01-17) |
Re: ANSI alias rules checker in GCC, other optimizing compilers andreybokhanko@gmail.com (Andrey Bokhanko) (2007-01-17) |
Re: ANSI alias rules checker in GCC, other optimizing compilers andreybokhanko@gmail.com (Andrey Bokhanko) (2007-01-17) |
Re: ANSI alias rules checker in GCC, other optimizing compilers ian@airs.com (Ian Lance Taylor) (2007-01-17) |
Re: ANSI alias rules checker in GCC, other optimizing compilers silvius.rus@gmail.com (Silvius Rus) (2007-01-17) |
Re: ANSI alias rules checker in GCC, other optimizing compilers ajonospam@andrew.cmu.edu (Arthur J. O'Dwyer) (2007-01-18) |
Re: ANSI alias rules checker in GCC, other optimizing compilers andreybokhanko@gmail.com (2007-01-20) |
From: | Ian Lance Taylor <ian@airs.com> |
Newsgroups: | comp.compilers |
Date: | 17 Jan 2007 17:30:09 -0500 |
Organization: | Compilers Central |
References: | 07-01-047 |
Keywords: | C, GCC, optimize |
Posted-Date: | 17 Jan 2007 17:30:09 EST |
andreybokhanko@gmail.com writes:
> Could you, please, suggest me what GCC does under "-Wstrict-aliasing"
> and "-Wstrict-aliasing=2"? What interests me is information from
> "compiler developer / power user" point of view -- that is, as much
> "under the hood" details as possible.
These options are pretty simple-minded. They both generate both false
negatives and false positives.
-Wstrict-aliasing warns when it sees "(T*)&x" where T is not void and
where T and the type of X have conflicting alias sets. Two types have
conflicting alias sets more or less if they are different ignoring
qualifiers. The type "char" does not conflict with anything. Adding
a restrict qualifier creates a subset of an alias set, so that two
different restrict qualified pointers are treated as pointing to types
which do not alias.
-Wstrict-aliasing=2 warns in the same case if the alias sets are
different at all. For example, it will warn about casts between
restrict qualified pointers.
These warnings apply only to casts.
A colleague of mine has developed a much more sophisticated alias
warning mechanism for gcc, which detect cases where an object is read
or written using the wrong type (i.e., cases where compiler
optimization is likely to produce an unexpected result). He expects
to send this patch to the gcc-patches@gcc.gnu.org mailing list in the
next week or two.
Ian
Return to the
comp.compilers page.
Search the
comp.compilers archives again.