swap(x,y)

Norman Diamond diamond at csl.sony.co.jp
Wed Sep 6 16:01:35 AEST 1989


In article <10790 at riks.csl.sony.co.jp>, I wrote:

>>>    *(int*)&x

In article <1560 at l.cc.purdue.edu>, cik at l.cc.purdue.edu (Herman Rubin) writes:

>> What if x is in a register?

In article <6029 at ficc.uu.net> peter at 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 at 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.



More information about the Comp.lang.c mailing list