home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / os / linux / 9913 < prev    next >
Encoding:
Internet Message Format  |  1992-09-07  |  1.6 KB

  1. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!wupost!uwm.edu!ogicse!unmvax!uservx.plk.af.mil!simonich
  2. From: simonich@uservx.plk.af.mil
  3. Newsgroups: comp.os.linux
  4. Subject: Re: GCC 2.2.2d bug
  5. Message-ID: <1992Sep4.210545.36040@uservx.plk.af.mil>
  6. Date: 4 Sep 92 21:05:45 GMT
  7. Article-I.D.: uservx.1992Sep4.210545.36040
  8. References: <1992Sep4.202913.14346@hippo.ru.ac.za> <1992Sep4.230902.2523@novell.com>
  9. Organization: Phillips Laboratory - Kirtland AFB
  10. Lines: 36
  11.  
  12. In article <1992Sep4.230902.2523@novell.com>, bboerner@novell.com (Brendan B. Boerner) writes:
  13. > In article <1992Sep4.202913.14346@hippo.ru.ac.za> pi@cs.sun.ac.za writes:
  14. >>I have found that gcc is generating the wrong code for the following
  15. >>code fragment:
  16. >>
  17. >>  int p = 10;
  18. >>  p = p++;
  19. >>
  20. >>From my C background, I have found the value to be 10.  Unfortunately
  21. >>(for the gcc maintainers) the result is 11.
  22. > I have this idea that if you posted this to comp.lang.c, Chris Torek or
  23. > someone similar would point out that this is correct behaviour.  My gut
  24. > feeling is that it SHOULD be 11 but I'm not a C guru.
  25. > Later,
  26. > Brendan
  27. > -- 
  28. > Brendan B. Boerner        Phone: 512/346-8380
  29. > Internet: bboerner@novell.com    MHS: bboerner@novell
  30. > Please use ^^^^^^^^^^^^^^^^^ if replying by mail.
  31.  
  32. I will admit that it isn't the ASCII C standard but on page 46 of 
  33. The C Programming Language (second edition) by Kernighan and Ritchie
  34. they give the specific example:
  35. "If n is 5, then
  36.  
  37.         x = n++;
  38.  
  39. sets x to 5, but
  40.  
  41.         x = ++n;
  42.  
  43. sets x to 6."
  44. I agree with a previous poster that this code fragment is IMHO, very
  45. poor code. 
  46.