This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH:[darwin] fix load of a misaligned double word
Brad Lucier writes:
> > On Dec 28, 2003, at 21:26, Brad Lucier wrote:
> >
> > >> Basically it is these two lines which are causing them:
> > >>
> > >> *(double*)(((int)(((int*)((___r1)-(1)))+1))+(((((int)(8))<<2))<<(3-2)))=(2*(1+2)<<2);
> > >> n = (1<<2) + 17 * sizeof (double) + (5<<2);
> > >>
> > >> *(double*)(((int)(((int*)((___r1)-(1)))+1))+(((((int)(9))<<2))<<(3-2)))=(2*n);
> >
> > Also if you did not violate ANSI C aliasing rules this would not really
> > be a problem.
>
> I'be been thinking about this. The memory location is accessed
> only as a double. There is no violation of the aliasing rules that
> I can see.
Regardless of whether this is an aliasing violation, constructing a
misaligned pointer by use of pointer casts and then using that pointer
is not well-defined. (C99 Section 6.2.2.3, Pointers.) Even if someone
changes the back end, there's no guarantee that gcc will do anything
useful with this code.
Andrew.