home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.linux
- Path: sparky!uunet!newsgate.watson.ibm.com!yktnews!admin!gumby!derek
- From: derek@watson.ibm.com (Derek Lieber)
- Subject: gcc compiler bug involving <linux/ctype.h>?
- Sender: news@watson.ibm.com (NNTP News Poster)
- Message-ID: <1992Aug26.020845.15618@watson.ibm.com>
- Date: Wed, 26 Aug 1992 02:08:45 GMT
- Reply-To: derek@watson.ibm.com (Derek Lieber)
- Disclaimer: This posting represents the poster's views, not necessarily those of IBM
- Nntp-Posting-Host: gumby.watson.ibm.com
- Organization: IBM T.J. Watson Research Center
- Lines: 32
-
- The program below prints:
- 1
- 1
- but should print:
- 0
- 1
-
- -------------------bug.c-------------------------
- #include <linux/ctype.h>
- main()
- {
- printf("%d\n", toupper('x') == toupper('y'));
- printf("%d\n", toupper('x') == toupper('X'));
- }
- -------------------------------------------------
-
- The problem seems to be due to the toupper macro defined in <linux/ctype.h>.
- The macro looks fine to me, but changing it from...
-
- #define toupper(c) (_ctmp=c,islower(_ctmp)?_ctmp-('a'-'A'):_ctmp)
-
- to...
-
- inline toupper(c) { return (_ctmp=c,islower(_ctmp)?_ctmp-('a'-'A'):_ctmp); }
-
- ...makes the problem go away.
-
- Is this a compiler bug? (I'm using gcc 2.2.2).
-
- --
- Derek Lieber
- derek@watson.ibm.com
-