|
|
Darren New wrote:
> I'll post the answer tomorrow morning. :-)
The answer I was *thinking* was when the native bit pattern for a "zero"
value isn't all zeros for one or more of the basic types.
For example, I worked on an AT&T 3B2 for a while, where the bit pattern for
NULL was 0x80000000. So
static union { void* p, long l } x;
static union { long l, void* p } y;
would wind up with different values for x.l and y.l even before any
assignments. The same could happen with floats/doubles being first, if
you're not using IEEE754.
The standard says a static union is initialized to the zero value for the
first element. I got curious once and actually tracked it down in the standard.
--
Darren New, San Diego CA, USA (PST)
"How did he die?" "He got shot in the hand."
"That was fatal?"
"He was holding a live grenade at the time."
Post a reply to this message
|
|