Mail Archives: djgpp-workers/2003/04/23/05:00:40
Hello.
Martin Stromberg wrote:
>
> Richard said:
[snip]
> > > -fstrict-aliasing'
> > > Allows the compiler to assume the strictest aliasing rules
> > > applicable to the language being compiled. For C (and C++), this
> > > activates optimizations based on the type of expressions. In
> > > particular, an object of one type is assumed never to reside at
> > > the same address as an object of a different type, unless the
> > > types are almost the same. For example, an `unsigned int' can
> > > alias an `int', but not a `void*' or a `double'. A character type
> > > may alias any other type.
>
> (Sounds to me that "strictly aliased" (gcc term) should be named
> strictly UNaliased (my understanding of it).)
Yes, that would be a clearer name!
The set of strict aliases for something could be a set containing one item
(/the/ only pointer to the thing). Maybe strict aliasing was named by some
mathematicians? ;)
> > Time to get a new mail client, I think. It cut off the last half of my
> > message:
> >
> > The practice of reading from a different union member than the one
> > most recently written to (called "type-punning") is common. Even
> > with `-fstrict-aliasing', type-punning is allowed, provided the
> > memory is accessed through the union type.
>
> Ah. So the day we turn that one on (it isn't on yet, right?) we need
> to add many unions (I suspect we cast pretty much in the source).
gcc 3.3 (well, pre-releases) has a new warning option -Wstrict-aliasing, which
is enabled by -fstrict-aliasing. This is also included by default in -Wall.
-O2 turns on -fstrict-aliasing which turns on -Wstrict-aliasing. So if you use
gcc 3.3, you get the warning.
Bye, Rich =]
--
Richard Dawe [ http://www.phekda.freeserve.co.uk/richdawe/ ]
- Raw text -