Save to assign union member to each other ?
Lars Henrik Mathiesen
thorinn at diku.dk
Sat Feb 9 05:45:17 AEST 1991
michi at ptcburp.ptcbu.oz.au (Michael Henning) writes:
>Given
>union {
> int i;
> double d;
>} u;
>is it legal to assign one member of the union to another? Examples:
Under Semantics of 3.3.16.1 (Simple assignment), the C Standard says:
"If the value being stored in an object is accessed from another object
that overlaps in any way the storage of the first object, then the
overlap shall be exact and the two objects shall have qualified or
unqualified version of a compatible type; otherwise the behavior is
undefined."
The answer to your question is no.
--
Lars Mathiesen, DIKU, U of Copenhagen, Denmark [uunet!]mcsun!diku!thorinn
Institute of Datalogy -- we're scientists, not engineers. thorinn at diku.dk
More information about the Comp.lang.c
mailing list