This is the mail archive of the
mailing list for the GCC project.
Re: PATCH:[darwin] fix load of a misaligned double word
Bradley Lucier writes:
> On Dec 31, 2003, at 9:22 AM, Andrew Haley wrote:
> > 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.
> The pointer is not misaligned.
> > (C99 Section 220.127.116.11, Pointers.)
> I have a document n2794.pdf, which seems to be a draft of the standard,
> and can't find the section you're talking about.
I'm sorry, that's the section number in C90. It's 18.104.22.168 in C99.
You're allowed to convert a pointer to a pointer of another type and
convert it back again. But this
does arithmetic on an int* pointer and then this
converts this pointer to an int and then this
converts to a double* and uses the result as an lvalue.
It's quite clear from the standard that all you may do with a pointer
is convert it to a sufficiently aligned pointer of a different type
and then convert it back. You may not perform arithmetic on that
pointer in between.