avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Re: zero length array in nocommon


From: Ruud Vlaming
Subject: Re: [avr-gcc-list] Re: zero length array in nocommon
Date: Thu, 24 Sep 2009 11:45:26 +0200
User-agent: KMail/1.9.1

On Thursday 24 September 2009 10:51, David Brown wrote:

> As shown by the link you gave, zero-length arrays are only really valid 
> when they are the last element in a struct (they can be very useful there).
I cannot read any restrictions on the use of zero-length arrays. It states
"Zero-length arrays are allowed in GNU C" Period. And then an example 
is discussed about how it can be usefull.
 
> The problem boils down to that C requires every declared object to have 
> a unique address.  Theoretically, the compiler/linker could do this by 
> aliasing the zero-length array into the middle of something else that is 
> otherwise not addressed by the program.  But in practice, it is done by 
> allocating at least 1 byte to zero-length data.
Maybe true, but contraditory to my findings with gcc. When i keep it
in the common (as is done automatically) gcc has no problems
whatsoever with the zero length array, and indeed it address may 
overlap with other variables. It is up to the programmer i guess not
to misuse this 'feature'.

My question was, why is there a difference in behaviour, and i
hoped somebody could shine some light on this. But maybe 
it is like J"org says, just a bug.

R.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]