home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / c / 18284 < prev    next >
Encoding:
Text File  |  1992-12-13  |  1.7 KB  |  44 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!wupost!uwm.edu!news.mr.med.ge.com!rdsunx.crd.ge.com!bart!volpe
  3. From: volpe@bart.NoSubdomain.NoDomain (Christopher R Volpe)
  4. Subject: Re: Question to test general C knowledge
  5. Message-ID: <1992Dec13.051442.1867@crd.ge.com>
  6. Sender: volpe@bart (Christopher R Volpe)
  7. Nntp-Posting-Host: bart.crd.ge.com
  8. Reply-To: volpe@ausable.crd.ge.com
  9. Organization: GE Corporate Research & Development
  10. References: <Bz0A46.Cvu@watserv1.uwaterloo.ca> <19980@ksr.com> <1992Dec11.180939.20726@crd.ge.com> <1992Dec12.230520.771@thunder.mcrcim.mcgill.edu>
  11. Date: Sun, 13 Dec 1992 05:14:42 GMT
  12. Lines: 30
  13.  
  14. In article <1992Dec12.230520.771@thunder.mcrcim.mcgill.edu>, mouse@thunder.mcrcim.mcgill.edu (der Mouse) writes:
  15. |> In article <1992Dec11.180939.20726@crd.ge.com>, volpe@bart.NoSubdomain.NoDomain (Christopher R Volpe) writes:
  16. |> >                                                ^^^^^^^^^^^^
  17. |> > Why?
  18. |> 
  19. |> Based on a sequence like
  20. |> 
  21. |>         ! compute needed values
  22. |>         addl3   _i,$1,r0        ! compute value of ++i
  23. |>         ! sequence point; do accumulated side-effects
  24. |>         movl    r0,_i           ! store value of ++i into i
  25. |>         incl    _i              ! increment i
  26. |> 
  27. |> Thus we see the wisdom of ANSI's rule :-)
  28.  
  29. Umm. I question whether it would be legal for the compiler to emit
  30. such code. The reason is that the value of the "++i" expression is
  31. "the value of i after the assignment". The first assembly statement
  32. computes this value as "3". However, the "value of i after the assignment"
  33. is determined by the result of the "incl _i" statement, and that 
  34. value is 4, which contradicts the definition of the value of the "++i"
  35. expression. 
  36.  
  37. -Chris
  38.  
  39. -- 
  40. ==================
  41. Chris Volpe
  42. G.E. Corporate R&D
  43. volpecr@crd.ge.com
  44.