Hi, all.

Yesterday I observed different sizeof() of a union in a library function
and in the main program. The reason seems to be a forgotten #include
in a library source.

union U
{
   struct
   {
         <fields of defined types>            //  sizeof = 100
struct NeverDefined nf; // Unknown, definition not #included
   } S1

   struct
   {
         <fields of defined types>            //  sizeof = 20
   } S2
};

8c silently accept the above definition and sizeof(U) is 100.  ???
The sources which include the definition of "NeverDefined" are
regularly compiled too and sizeof(U) = 100 + sizeof(NeverDefined).

This happens only if the undefined field is the last of the structure.
If it is followed by other (defined or not defined) field(s), the compiler
correctly detects the error.

Is this behaviour correct ?

Thanks in advance.

a.verardo





Reply via email to