>>>>> "Richard" == Richard Henderson <[EMAIL PROTECTED]> writes:

 >> > No it is not, once you take the address (which should be
 >> rejected), it > is of type "unsigned int *" and not unaligned
 >> variable, passing it to > memcpy assumes the type alignment is the
 >> natural alignment.
 >> 
 >> That argument doesn't make sense to me.

 Richard> It is nevertheless correct.  Examine all of the parts of the
 Richard> expression.

 Richard> In particular, "&s->b".  What type does it have?  In an
 Richard> ideal world, it would be "pointer to unaligned integer".
 Richard> But we have no such type in our type system, so it is
 Richard> "pointer to integer".  This expression is ONLY THEN passed
 Richard> to memcpy.  At which point we query the argument for its
 Richard> alignment, and get the non-intuitive result.

The underlying problem is that the type system in GCC isn't right.

The C type system has data of various kinds, pointers to them,
structures made up of the above, etc.  GCC extends the type system by
introducing selectable alignment.  But it doesn't do it consistently.
We have int, we have *int, we have packed int, but we don't have 
*packed int.

So the outcome is "correct" only if you treat GCC's incomplete type
system as correct, which I don't agree with.  This does mean,
unfortunately, that the fix is to correct that incompleteness, which
was said to be a nontrivial task.

    paul

Reply via email to