Re: ANSI alias rules checker in GCC, other optimizing compilers

"Andrey Bokhanko" <andreybokhanko@gmail.com>
17 Jan 2007 17:33:18 -0500

          From comp.compilers

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)
| List of all articles for this month |

From: "Andrey Bokhanko" <andreybokhanko@gmail.com>
Newsgroups: comp.compilers
Date: 17 Jan 2007 17:33:18 -0500
Organization: Compilers Central
References: 07-01-047 <m3tzyqmfcd.fsf@gossamer.airs.com>
Keywords: C, GCC, optimize
Posted-Date: 17 Jan 2007 17:33:18 EST

On 16 Jan 2007 20:45:06 -0800, Ian Lance Taylor <ian@airs.com> wrote:
> 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.


Ian, thank you for detailed description.


If you allow me, a (possibly) stupid question: what do you mean by
"restrict qualified pointers"? Pointers with "restrict" C keyword? If
yes, does "-Wstrict-aliasing=2" warns on something like this?


void foo(restrict int *p1) {
      int *p2;
      p2 = p1; // p2 points to a restricted memory area, GCC warns?
      ...
}


Also, can you give me examples of cases when GCC generates false
warnings and when it doesn't catch "proper" ANSI rules violations? Is
it due to internal GCC issues (like losing some type information in
IR) or due to perplexities of ANSI rules?


> 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.


And the last question: are your colleague based his implementation on
an openly available paper, or devised everything himself?


Thank you!


Yours,
Andrey


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.