Re: [AD] Proposal: removal of zero-sized arrays

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Iv'e tried to understand [#15] a number of
times this week, but I can't read out from it that 
static initialisation is undefined, Eric. 
Probably my Enklisch is too poor, but to me it
speaks about the behaviovior of a certain instance of
a struct with a flexible array member, that happens 
to have no elements (and it says that it is in that
case undefined when accesing obj.arr[0]).
..and also specifies the value sizeof(struct flex)
..and that obj.arr[i] works fine if i < "number
of elements" of the instance.

I haven't either found somewhere else anything that 
indicates that static  initialisation should be 
undefined.
/C

At 09:06 2002-10-11 +0200, you wrote:
>> If that's the case, then does ISO C99 provide for static initialisation
>> of such structures?
>
>No, it doesn't.
[...]
>[#2] A structure or union shall not contain  a  member  with
>       incomplete or function type, except that the last element of
>       a structure may have incomplete array type.  Hence it  shall
>       not contain an instance of itself (but may contain a pointer
>       to an instance of itself).
>
>[#15] As a special case, the last element of a structure may
>       be  an  incomplete  array  type.   This is called a flexible
>       array member, and the size of the structure shall  be  equal
>       to  the offset of the last element of an otherwise identical
>       structure that replaces the flexible array  member  with  an
>       array  of  one  element.   When  an  lvalue  whose type is a
>       structure with a flexible array member is used to access  an
>       object,  it  behaves  as if that member were replaced by the
>       longest array that would not make the structure larger  than
>       the  object  being  accessed.   If  this array would have no
>       elements, then it behaves as if it has one element, but  the
>       behavior  is undefined if any attempt is made to access that
>       element.




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/