This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Linux and aliasing?
toon@moene.indiv.nluug.nl (Toon Moene) writes:
> Jeffrey A Law wrote:
>
> > Mark Mitchell wrote:
>
> > > Either
> > > 1. Leave it as it is (the Linux kernel will need -fno-strict-aliasing).
>
> > This is my strong preference.
> >
> > I see no need to make conforming, portable code run slower.
>
> Exactly. Remember that a standard is a contract between producer and
> (end-)user, in our case: between compiler writer and C programmer.
>
> "We won't optimize your constructs away as long as you program
> according to said standard"
Erm, there seem to be some misunderstandings about the C standard in
this discussion.
My C9x draft says:
6.2.6.1
[#5] Certain object representations need not represent a
value of the object type. If the stored value of an object
has such a representation and is accessed by an lvalue
expression that does not have character type, the behavior
is undefined. If such a representation is produced by a
side effect that modifies all or any part of the object by
an lvalue expression that does not have character type, the
behavior is undefined.37) Such a representation is called a
trap representation.
Now it says undefined behaviour is:
3.18
[#1] undefined behavior
behavior, upon use of a nonportable or erroneous program
construct, of erroneous data, or of indeterminately valued
objects, for which this International Standard imposes no
requirements
So it imposes no requirements on what to do when it happen. This means gcc
is free to do what it wants. This includes unreasonable things, or reasonable
things. I think turning alias analysis off in this case is reasonable, and
of course fully standards compliant. Also the argument "that will slow
down legal programs" is non sense, because there are no strictly conforming
programs which can do this.
-Andi
P.S.: Toon, this is not Fortran ;)
--
This is like TV. I don't like TV.