Path: utzoo!attcan!uunet!lll-winken!ames!pasteur!ucbvax!ernie.Berkeley.EDU!jas From: jas@ernie.Berkeley.EDU (Jim Shankland) Newsgroups: comp.lang.c Subject: Re: malloc impossible? Message-ID: <27499@ucbvax.BERKELEY.EDU> Date: 12 Jan 89 18:47:45 GMT References: <19@xenlink.UUCP> <225800106@uxe.cso.uiuc.edu> <310@twwells.uucp> <9342@smoke.BRL.MIL> <15427@mimsy.UUCP> <9351@smoke.BRL.MIL> Sender: usenet@ucbvax.BERKELEY.EDU Reply-To: jas@ernie.Berkeley.EDU (Jim Shankland) Organization: University of California, Berkeley Lines: 26 In article <9351@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) writes: >Assuming that integers could not also live in floating-point space, >C would not be implementable on such a hypothetical architecture. >Consider > union { > double d; > int i; > } u; > u.d = 123.0; > printf("%d\n", u.i); >This is required to work, although the specific value printed of course >depends on details of numeric representation on the specific system. >All data object types in C must be able to live in the same kind of space. Well, this is getting pretty esoteric, I suppose, but if I were implementing (C - malloc) on such a machine, couldn't I reserve space for this union in both fp space and integer space? The value ouput by the printf above would, of course, be entirely unaffected by the preceding assignment; but as you say, the value printed is system-specific, anyway. In other words, are unions *required* to overlay their members onto the same physical storage? Jim Shankland jas@ernie.berkeley.edu "I've been walking in a river all my life, and now my feet are wet"