swap(x,y)

Wm E Davidsen Jr davidsen at crdos1.crd.ge.COM
Thu Sep 7 02:43:34 AEST 1989


In article <6029 at ficc.uu.net>, peter at ficc.uu.net (Peter da Silva) writes:
|  In article <1560 at l.cc.purdue.edu>, cik at l.cc.purdue.edu (Herman Rubin) writes:
|  > In article <10790 at riks.csl.sony.co.jp>, diamond at csl.sony.co.jp (Norman Diamond) writes:
|  > >    *(int*)&x
|  
|  > What if x is in a register?
|  
|  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...

  I wouldn't bother with a compiler which allowed me to take the address
of a register variable, either. On a quality of implementation scale I
rate that as zero.

  This brings to mind a good point, that implementation of a swap should
not bypass any internal checking, such as 'const' declarations.
-- 
bill davidsen	(davidsen at crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen)
"The world is filled with fools. They blindly follow their so-called
'reason' in the face of the church and common sense. Any fool can see
that the world is flat!" - anon



More information about the Comp.lang.c mailing list