Path: utzoo!utgpu!attcan!uunet!lll-winken!lll-tis!ames!mailrus!purdue!i.cc.purdue.edu!k.cc.purdue.edu!l.cc.purdue.edu!cik From: cik@l.cc.purdue.edu (Herman Rubin) Newsgroups: comp.lang.c Subject: Re: Unions Message-ID: <981@l.cc.purdue.edu> Date: 23 Oct 88 12:15:09 GMT References: <322@hrc.UUCP> <2699@hound.UUCP> <976@l.cc.purdue.edu> <8724@smoke.BRL.MIL> Organization: Purdue University Statistics Department Lines: 25 In article <8724@smoke.BRL.MIL>, gwyn@smoke.BRL.MIL (Doug Gwyn ) writes: > In article <976@l.cc.purdue.edu> cik@l.cc.purdue.edu (Herman Rubin) writes: > >One complaint that I have about the C compilers I have used is that they > >do not support register unions. > > Please explain how that would work. Or else (preferably) stop complaining. Here is a very simple example. BTW, I have seen C sources which use precisely this construction. union un {*int i; *float f;}; ..... register union un var1, var2; Can anyone give me any conceivable reason why this union, whose size is exactly one register on the machines I have tried it on, is not put into an available register? On one of the machines (Pyramid), local variables were normally put into registers, but the compiler would not put the union there. I know this particular case can be done with casts, but other cases cannot. -- Herman Rubin, Dept. of Statistics, Purdue Univ., West Lafayette IN47907 Phone: (317)494-6054 hrubin@l.cc.purdue.edu (Internet, bitnet, UUCP)