Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rutgers!labrea!decwrl!decvax!ima!haddock!karl From: karl@haddock.ISC.COM (Karl Heuer) Newsgroups: comp.lang.c Subject: Cast into union (was: Function prototypes versus open()) Message-ID: <763@haddock.ISC.COM> Date: Mon, 20-Jul-87 16:29:57 EDT Article-I.D.: haddock.763 Posted: Mon Jul 20 16:29:57 1987 Date-Received: Wed, 22-Jul-87 01:32:58 EDT References: <18346@ucbvax.BERKELEY.EDU> <8042@utzoo.UUCP> Reply-To: karl@haddock.ISC.COM (Karl Heuer) Organization: Interactive Systems, Boston Lines: 22 In article <732@jenny.cl.cam.ac.uk> am@cl.cam.ac.uk (Alan Mycroft) writes: >The problem is that C does not include all the operations one would expect on >union types... In C we could say > union intorptr { int a; char *b;}; > extern f(union intorptr); > g() { f((union intorptr)3);} NOT IN ANSI. I can't find any mention of this in the Rationale document, but I presume the reason X3J11 didn't add this (assuming they thought of it) is the usual Lack of Prior Art. The way to get this into the *next* standard is to convince vendors to add it as an extension. Now, let's examine this idea. I like the semantics, but the syntax isn't all-powerful. What if you want to initialize a member of a non-rvalue type, such as "char" or "short"? Does it only work if there is no "int" member for it to conflict with? Given a union of { long; char[4] }, can you initialize the array member? How? These questions need to be addressed, and it would be inappropriate for X3J11 to do so. Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint