Path: utzoo!utgpu!water!watmath!clyde!rutgers!cmcl2!brl-adm!husc6!mailrus!umix!uunet!mcrware!jejones From: jejones@mcrware.UUCP (James Jones) Newsgroups: comp.lang.c Subject: Re: register unions Summary: unions in registers Keywords: registers, unions Message-ID: <604@mcrware.UUCP> Date: 20 Feb 88 14:59:10 GMT References: <1229@eneevax.UUCP> <7258@brl-smoke.ARPA> Distribution: comp.lang.c Organization: Microware Systems Corp., Des Moines, Ia. Lines: 32 In article <7258@brl-smoke.ARPA>, gwyn@brl-smoke.ARPA (Doug Gwyn ) writes: > 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? The place I can see people wanting unions to live in registers is something like register union { woof *wp; char *cp; ... } mumble; (Actually, this isn't great insight on my part; I've heard people say, "Gee, it would be nice if a compiler let you do this...") There are some low-level cases in which one would like to add a byte offset to a pointer that usually points at something bigger than one byte, and still keep the pointer in a register. (Of course, compilers should all be smart enough to figure out what should go in registers themselves, right? We don't need no steenkin' register declara- tions! :-) (I *do* recognize the advantages of letting the compiler figure out what can go into a register, what the lifetimes of such variables are, etc.--it's just that if the compiler *can* really put such a union in a register itself, it seems to me that the programmer should be able to specify explicitly that he thinks it's important that the union be in a register.) James Jones