home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 3756 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: sable.ox.ac.uk!worc0223
  2. From: worc0223@sable.ox.ac.uk (Benjamin Hutchings)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: x ^= y ^= x ^= y;
  5. Date: 22 Feb 1996 20:20:17 GMT
  6. Organization: Oxford University, England
  7. Message-ID: <4gij61$81i@news.ox.ac.uk>
  8. References: <1286.6624T1439T237@cs.ruu.nl>
  9. NNTP-Posting-Host: sable.ox.ac.uk
  10.  
  11. In article <1286.6624T1439T237@cs.ruu.nl>,
  12. Wessel Dankers <wsldanke@cs.ruu.nl> wrote:
  13. [...]
  14. >Which can of course be rewritten as:
  15. >
  16. > x ^= y;
  17. > y ^= x;
  18. > x ^= y;
  19. >
  20. >or if you want it real fancy:
  21. >
  22. > x ^= y ^= x ^= y;
  23.  
  24. Not guaranteed to work! Read the FAQ in one of the C newsgroups. This is a
  25. common lame mistake. The order of evaluation is not guaranteed and the
  26. compiler is entitled to optimise the assignments to execute in a variety of
  27. different ways. On some compilers this will work, on others not.
  28. -- 
  29. --
  30. Ben Hutchings, student. Finger me on worc0223@sable.ox.ac.uk for various info.
  31. email: benjamin.hutchings@worc.ox.ac.uk  WWW: http://sable.ox.ac.uk/~worc0223/
  32. Users of the world unite! You have nothing to lose but your Micro$oft software
  33.