Unions

Herman Rubin cik at l.cc.purdue.edu
Sun Oct 23 22:15:09 AEST 1988


In article <8724 at smoke.BRL.MIL>, gwyn at smoke.BRL.MIL (Doug Gwyn ) writes:
> In article <976 at l.cc.purdue.edu> cik at 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 at l.cc.purdue.edu (Internet, bitnet, UUCP)



More information about the Comp.lang.c mailing list