home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / c / 18212 < prev    next >
Encoding:
Internet Message Format  |  1992-12-11  |  1.5 KB

  1. Path: sparky!uunet!ornl!utkcs2!darwin.sura.net!spool.mu.edu!olivea!charnel!sifon!thunder.mcrcim.mcgill.edu!mouse
  2. From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Question to test general C knowledge
  5. Message-ID: <1992Dec11.193346.22908@thunder.mcrcim.mcgill.edu>
  6. Date: 11 Dec 92 19:33:46 GMT
  7. References: <1992Dec10.195832.4305@leland.Stanford.EDU> <behrenss.724026637@hphalle6>
  8. Organization: McGill Research Centre for Intelligent Machines
  9. Lines: 30
  10.  
  11. In article <behrenss.724026637@hphalle6>, behrenss@Informatik.TU-Muenchen.DE (Soenke Behrens) writes:
  12.  
  13. > Hmm. ++i would mean it is incremented before using it in the
  14. > expression.  Means I get three.
  15.  
  16. Er, no.  ++i means the value is the value after the increment.  The
  17. increment itself may happen any time between the previous and next
  18. sequence points; in particular, it may happen after the assignment, and
  19. it may take the form of an increment or a storing of the new value.
  20.  
  21. That is, it could be
  22.  
  23.     i = (old value plus 1)      -- assignment
  24.     i = (old value plus 1)      -- increment
  25. or
  26.     i = (old value plus 1)      -- assignment
  27.     i = (current value plus 1)  -- increment
  28. or
  29.     i = (old value plus 1)      -- increment
  30.     i = (old value plus 1)      -- assignment
  31.  
  32. Or, of course, since the same lvalue is being modified more than once,
  33. this is all academic anyway; it's equally legal to compile
  34.  
  35.     i = 42                      -- undefined behavior
  36.  
  37.                     der Mouse
  38.  
  39.                 mouse@larry.mcrcim.mcgill.edu
  40.