This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Arrays and Alignment
Michael N. Moran wrote:-
> >>% gcc -o main main.c ; main
> >>
> >>__alignof__(achar):32
> >>__alignof__(a[1]):1
> >>&a: 08049740
> >>sizeof(a):32
> >>sizeof(a[0]):1
> >>&a[0]: 08049740
> >>&a[1]: 08049741 <<<<<<<<<<<< I expected this to be 08049760
> >>
> >>
> >
> >You can't have both. That would require to put padding between array
> >elements, which is not allowed (unlike structure members).
> >
> >Andreas.
> >
> >
> Andreas,
>
> Thanks for the instantaneous reply :-)
>
> I must confess, however, that I don't understand what you mean
> by "both". Do you mean (1) array alignment and (2) array element
He means, I think, that &a[n] == &a[0] + n * sizeof (a[0]) is an
inescapable fact of life.
Neil.