Does traditional C allow initializing a union?

Tim Waugh tim@cyberelk.demon.co.uk
Wed Oct 14 06:09:00 GMT 1998


On Tue, 13 Oct 1998, Carlo Wood wrote:

> The problem with this is that the compiler can't know
> which type you are refering to.  In this case it would probably
> result in the same for each element, but it is still ambiguous.

I think ANSI says that union initialization is taken to apply to the first
declared member of the union.  So, union { char a; int b; } c = { 0 }
leaves some of c.b uninitialized.

But then, I'm not looking at a copy of the standard, so..

Tim.
*/




More information about the Gcc mailing list