DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT

Jamie Lokier jamie@shareable.org
Mon Apr 21 21:14:00 GMT 2003


Richard Kenner wrote:
>     Are you saying that it should be an error to take the address of such
>     an object?
> 
> What I was thinking was more that it should be an error to create an object
> whose alignment is less than that of its type, but you correctly point out
> that an alternate solution is to allow that but, like a bitfield, to forbid
> taking its address.

Oh.  I like yours more!  Much simpler, otherwise you still need code
in the compiler to dereference at small alignments, which there
doesn't seem to be at present.

(Another solution is to say that the object's type has the same
alignment as the object itself (which may be different from the type
used in the object's declaration)).

Then you could take its address and dereference it, getting (in
principle) code which does handle the smaller alignment, and the
ability to pass that address around.

-- Jamie



More information about the Gcc mailing list