andrew@orca.UUCP (Andrew Klossner) (03/26/84)
"Another solution would be to clear the unused parts of the
union wherever a store is done. In many cases (admittedly not
all) this would be very cheap."
In some cases it can't be done at all:
struct {
union {char c; double d;} u;
} structure;
fill_char(pc) char *pc; {*pc = ~0;}
main() {
...
fill_char(&(structure.u.c));
...
}
The code generated for "fill_char" has no way of knowing that the
character to which it's been given a pointer is a member of a larger
union, the excess of which must be cleared.
-- Andrew Klossner (decvax!tektronix!orca!andrew) [UUCP]
(orca!andrew.tektronix@rand-relay) [ARPA]