Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!gem.mps.ohio-state.edu!ginosko!uunet!kddlab!titcca!sragwa!wsgw!socslgw!diamond From: diamond@csl.sony.co.jp (Norman Diamond) Newsgroups: comp.lang.c Subject: Re: swap(x,y) Message-ID: <10809@riks.csl.sony.co.jp> Date: 6 Sep 89 06:01:35 GMT References: <8350@boring.cwi.nl> <1560@l.cc.purdue.edu> <6029@ficc.uu.net> Reply-To: diamond@riks. (Norman Diamond) Organization: Sony Computer Science Laboratory Inc., Tokyo, Japan Lines: 26 In article <10790@riks.csl.sony.co.jp>, I wrote: >>> *(int*)&x In article <1560@l.cc.purdue.edu>, cik@l.cc.purdue.edu (Herman Rubin) writes: >> What if x is in a register? In article <6029@ficc.uu.net> peter@ficc.uu.net (Peter da Silva) writes: >What if it is? This is a quality-of-implementation issue. A good optimiser >will cancel out all the extra loads and stores. I'm sure you wouldn't bother >with a compiler with a poor optimiser... Actually Mr. Rubin was (almost) right, for a change. He meant, what if x is declared as register. It's illegal to apply & to a register even if no loads or stores are generated. If a particular implementation allowed it after a suitable warning, would that be an advantage or a (portability-discouraging) disadvantage? -- -- Norman Diamond, Sony Corporation (diamond@ws.sony.junet) The above opinions are inherited by your machine's init process (pid 1), after being disowned and orphaned. However, if you see this at Waterloo or Anterior, then their administrators must have approved of these opinions.