home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / linux / 9111 < prev    next >
Encoding:
Internet Message Format  |  1992-08-26  |  1.6 KB

  1. Path: sparky!uunet!gatech!bloom-beacon!eru.mt.luth.se!lunic!sunic!mcsun!news.funet.fi!hydra!klaava!klaava!hurtta
  2. From: hurtta@cs.Helsinki.FI (Kari E. Hurtta)
  3. Newsgroups: comp.os.linux
  4. Subject: Re: gcc compiler bug involving <linux/ctype.h>?
  5. Message-ID: <HURTTA.92Aug26131805@plootu.Helsinki.FI>
  6. Date: 26 Aug 92 11:18:05 GMT
  7. References: <1992Aug26.020845.15618@watson.ibm.com>
  8. Sender: news@klaava.Helsinki.FI (Uutis Ankka)
  9. Organization: Department of Computer Science, University of Helsinki, Finland
  10. Lines: 36
  11. In-Reply-To: derek@watson.ibm.com's message of 26 Aug 92 02: 08:45 GMT
  12.  
  13. In article <1992Aug26.020845.15618@watson.ibm.com> derek@watson.ibm.com (Derek Lieber) wrote:
  14. >    printf("%d\n",  toupper('x') == toupper('y'));
  15. > The problem seems to be due to the toupper macro defined in <linux/ctype.h>.
  16. > The macro looks fine to me, but changing it from...
  17. > #define toupper(c)          (_ctmp=c,islower(_ctmp)?_ctmp-('a'-'A'):_ctmp)
  18.  
  19. So printf is expanded to:
  20. printf("%d\n",  
  21.     (_ctmp='x',islower(_ctmp)?_ctmp-('a'-'A'):_ctmp)
  22.     ==
  23.     (_ctmp='y',islower(_ctmp)?_ctmp-('a'-'A'):_ctmp)
  24.     );
  25.  
  26. There is two assigment to _ctmp in same expression and there _isn't_
  27. any sequence point what apply ('==' isn't sequence point).
  28.  
  29. So it can be executed in follow order:
  30.     _ctmp='x'
  31.     _ctmp='y'
  32.     islower(_ctmp)?_ctmp-('a'-'A'):_ctmp
  33.     islower(_ctmp)?_ctmp-('a'-'A'):_ctmp
  34.  
  35. Notice that sequrce point (',') after _ctmp='x' didn't apply because
  36. assigment _ctmp='y' isn't argument of that operation (','). 
  37.  
  38. So error is in macro.
  39. (Maybe I don't say it clearly ... :-))
  40.  
  41.  
  42. - K E H
  43. ( Kari.Hurtta@Helsinki.FI,
  44.   hurtta@cc.Helsinki.FI,
  45.   hurtta@cs.Helsinki.FI,
  46.   HURTTA@FINUH.BITNET
  47. )
  48.