Hello,

I vaguely remember there was a recent, maybe within last two months, discussion
about semantics of union initialization where sizeof(first member) is less than
sizeof(union). The question was whether it's okay to initialize just that first
member and leave garbage bits in the other, larger, members of the union, like
in this example:

union A {
    char a;
    long : 0;
};

void fn(void *);

void my(void)
{
    union A a = { 0 };
    fn(&a);
}

(except in my example there's no other named member, but I think the example
in that discussion was less contrived)

Perhaps somebody remembers where it was (I'm thinking Bugzilla) and could point
me to it? My attempts to search for it aren't turning anything up so far.

If someone knows what semantics GCC implements, that also would be welcome.

Thank you.
Alexander

Reply via email to