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

"Silvius Rus" <silvius.rus@gmail.com>
17 Jan 2007 17:44:55 -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: "Silvius Rus" <silvius.rus@gmail.com>
Newsgroups: comp.compilers
Date: 17 Jan 2007 17:44:55 -0500
Organization: Compilers Central
References: 07-01-047
Keywords: C, GCC, analysis
Posted-Date: 17 Jan 2007 17:44:55 EST

On Jan 16, 9:45 am, andreybokha...@gmail.com wrote:
> 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.


GCC looks for expressions such as (int*) &some_float. It warns that
if you take the address of a variable of type A and cast it to a
pointer to type B, this may cause problems when the types are
incompatible. The problems actually should occur only if there is
data flow, e.g., if you define something as float and then use it as
int. The current implementation in GCC only looks for expression
level patterns, and does not verify that data flow exists.


I am about to send in a patch to GCC 4.3 that will address some
shortcomings. The new implementation performs single function
(intraprocedural) alias and data flow analysis to rule out false
negatives and to discover more cases which are not caught by the
current implementation, such as aliases through malloc-ed memory.


> Also, what methods other optimizing compilers use to check
> conformity of user code with ANSI aliasing rules? Is there an
> "industry-wide" set of options / conventions?


I am not sure, but would say no. The aliasing rules are described in
language standards. The main references are C Standard ISO/IEC
9899:1999, section 6.5, paragraph 7, and the C++ Standard ISO/IEC
14882:1998, section 3.10, paragraph 15, plus a few more issues related
to aliased structures. Like other faith-inspiring fat books, the
standards are subject to interpretation and I am not aware of any such
industry-wide agreement.


Hope this helps,
Silvius



Post a followup to this message

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