This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: attribute data structure rewrite
Andreas Schwab <schwab@suse.de> writes:
> "Giovanni Bajo" <giovannibajo@libero.it> writes:
>
>> Anothing thing I have been shown today is that we currently reject this:
>>
>> ----------------------------------------
>> #include <stddef.h>
>> #include <stdio.h>
>>
>> struct A { char foo[10]; };
>>
>> void bar(void) {
>> int i;
>> for (i=0;i<10;i++)
>> printf("%d\n", offsetof(struct A, foo[i]));
>> }
>> --------------------------------------
>>
>> but we used to accept it. Any idea about its legality? Workarounds?
>
> offsetof (struct A, foo[0]) + i * sizeof (foo[0])
Of course, that doesn't compile either, but you get the idea. :-)
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."