Path: utzoo!utgpu!water!watmath!clyde!rutgers!umd5!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: register unions Keywords: registers, unions Message-ID: <7258@brl-smoke.ARPA> Date: 13 Feb 88 07:44:01 GMT References: <1229@eneevax.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Distribution: comp.lang.c Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 18 I think it's a valid notion. Notice that the compiler would have to determine whether or not to assign a genuine register variable for the union based on what the member types are (they must all be compatible with the register). Also, only non-scratch registers could be allocated, so for example on a 68000 register D0, used as a scratch register in the generated code, would not be assigned to such a union. Which registers you got would of course depend on the register allocation strategy of the compiler. (You may get stack storage instead, if it runs out of registers.) You may need to add a check for & being applied to such a union, which should be illegal by normal C rules but may not be checked for in a compiler that didn't think unions would ever be in real registers. On the other hand, I don't think this is nearly as useful as you seem to think it would be. Why would you want to twiddle specific registers when not having to be concerned with such matters is the whole point of using a higher-level language?