Steve Bennett <[EMAIL PROTECTED]> wrote:

> Bad news!
>
> sizeof(test1) is 12
> offsetof(test1, more) is 8
> offsetof(test1, dummy) is 10
>
> I suppose this is the bit you are referring to:
> >   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 unspecified
> >   length.97)
>
> That 'of unspecified length' might well account for this behaviour.

I don't see this. Let us try to do what's in the text:

Use this struct:

struct test1 { 
        char blerg[1]; 
        char type[4]; 
        char flibble[3]; 
        char more[2]; 
        char dummy[]; 
}; 

Replace the flex array with an  an  array of unspecified (which means
irrelevent) length:

struct test2 { 
        char blerg[1]; 
        char type[4]; 
        char flibble[3]; 
        char more[2]; 
        char dummy[1]; 
}; 

Now, sizeof(test1) needs to be == offsetof(test2, dummy);

It seems that this is mot the case for GCC.

Jörg

-- 
 EMail:[EMAIL PROTECTED] (home) Jörg Schilling D-13353 Berlin
       [EMAIL PROTECTED]                (uni)  
       [EMAIL PROTECTED]     (work) Blog: http://schily.blogspot.com/
 URL:  http://cdrecord.berlios.de/old/private/ ftp://ftp.berlios.de/pub/schily

Reply via email to