Union type conversions

der Mouse mouse at mcgill-vision.UUCP
Sat Jun 25 15:35:18 AEST 1988


In article <5754 at bloom-beacon.MIT.EDU>, tada at athena.mit.edu (Michael Zehr) writes:
> So what it boils down to, is whether casting into a union type is
> legal and portable

Ouch.  I just searched through K&R V2 for a description of what may be
cast to what.  Nowhere did I find anything that comes right out and
*says* you can't cast to an aggregate type.  However, I also found
nothing explicitly requiring it to even compile, much less work.

Casting a type to a union which has a member of that type is certainly
a reasonable operation.  However, so are many other things which aren't
allowed, such as comparing aggregate types for equality....

Legal or not, I think we can be confident it isn't portable.

Could someone with a copy of the draft standard say just how much
latitude it allows on this point?

> (i don't want to just play with it til it works and then discover
> that it only works by accident on my compiler :-).

If only everyone were so sensible.

					der Mouse

			uucp: mouse at mcgill-vision.uucp
			arpa: mouse at larry.mcrcim.mcgill.edu



More information about the Comp.lang.c mailing list