home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / linux / 9093 < prev    next >
Encoding:
Text File  |  1992-08-25  |  1.2 KB  |  46 lines

  1. Newsgroups: comp.os.linux
  2. Path: sparky!uunet!newsgate.watson.ibm.com!yktnews!admin!gumby!derek
  3. From: derek@watson.ibm.com (Derek Lieber)
  4. Subject: gcc compiler bug involving <linux/ctype.h>?
  5. Sender: news@watson.ibm.com (NNTP News Poster)
  6. Message-ID: <1992Aug26.020845.15618@watson.ibm.com>
  7. Date: Wed, 26 Aug 1992 02:08:45 GMT
  8. Reply-To: derek@watson.ibm.com (Derek Lieber)
  9. Disclaimer: This posting represents the poster's views, not necessarily those of IBM
  10. Nntp-Posting-Host: gumby.watson.ibm.com
  11. Organization: IBM T.J. Watson Research Center
  12. Lines: 32
  13.  
  14. The program below prints:
  15.      1
  16.      1
  17. but should print:
  18.      0
  19.      1
  20.  
  21. -------------------bug.c-------------------------
  22. #include <linux/ctype.h>
  23. main()
  24.    {
  25.    printf("%d\n",  toupper('x') == toupper('y'));
  26.    printf("%d\n",  toupper('x') == toupper('X'));
  27.    }
  28. -------------------------------------------------
  29.  
  30. The problem seems to be due to the toupper macro defined in <linux/ctype.h>.
  31. The macro looks fine to me, but changing it from...
  32.  
  33. #define toupper(c)          (_ctmp=c,islower(_ctmp)?_ctmp-('a'-'A'):_ctmp)
  34.  
  35. to...
  36.  
  37. inline  toupper(c) { return (_ctmp=c,islower(_ctmp)?_ctmp-('a'-'A'):_ctmp); }
  38.  
  39. ...makes the problem go away.
  40.  
  41. Is this a compiler bug? (I'm using gcc 2.2.2).
  42.  
  43. -- 
  44. Derek Lieber
  45. derek@watson.ibm.com
  46.