This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Why so bad optimized code ?
- To: Mike Stump <mrs at windriver dot com>
- Subject: Re: Why so bad optimized code ?
- From: Jamie Lokier <egcs at tantalophile dot demon dot co dot uk>
- Date: Sat, 24 Mar 2001 23:42:04 +0100
- Cc: amylaar at cambridge dot redhat dot com, denisc at overta dot ru, gcc at gcc dot gnu dot org
- References: <200103210203.SAA20108@kankakee.wrs.com>
Mike Stump wrote:
> > From: Joern Rennecke <amylaar@cambridge.redhat.com>
> > To: denisc@overta.ru (Denis Chertykov)
> > Date: Wed, 21 Mar 2001 00:30:35 +0000 (GMT)
> > Cc: gcc@gcc.gnu.org
>
> > > int main(void)
> > > {
> > > time->day = 5;
> > > time->hour= 9;
> > > time->min = 10;
> > > time->sec =10;
> > > }
>
> > We have two mechanisms that could be used to do that:
> > - (only if -fstrict-aliasing is enabled): Although the individual components
> > are characters, the dereference is of a structure pointer, not of a
> > character pointer, so I suppose the memory accesses should get non-null
> > alias sets.
>
> Nope, don't think so?! char can alias anything, including the
> structure pointer.
Although a general "char *" can alias anything (as a special case),
dereferencing a struct field does not have the same property. E.g. in
this case the char struct fields _can_ alias other targets of "char *"
pointers, for the same reason that int struct fields can alias other
targets of "int *" pointers and in some cases int fields of other struct
types. However the char struct fields cannot alias e.g. other int
types.
So the generated code could be better.
-- Jamie