home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!gatech!bloom-beacon!eru.mt.luth.se!lunic!sunic!mcsun!news.funet.fi!hydra!klaava!klaava!hurtta
- From: hurtta@cs.Helsinki.FI (Kari E. Hurtta)
- Newsgroups: comp.os.linux
- Subject: Re: gcc compiler bug involving <linux/ctype.h>?
- Message-ID: <HURTTA.92Aug26131805@plootu.Helsinki.FI>
- Date: 26 Aug 92 11:18:05 GMT
- References: <1992Aug26.020845.15618@watson.ibm.com>
- Sender: news@klaava.Helsinki.FI (Uutis Ankka)
- Organization: Department of Computer Science, University of Helsinki, Finland
- Lines: 36
- In-Reply-To: derek@watson.ibm.com's message of 26 Aug 92 02: 08:45 GMT
-
- In article <1992Aug26.020845.15618@watson.ibm.com> derek@watson.ibm.com (Derek Lieber) wrote:
- > printf("%d\n", toupper('x') == toupper('y'));
- > 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)
-
- So printf is expanded to:
- printf("%d\n",
- (_ctmp='x',islower(_ctmp)?_ctmp-('a'-'A'):_ctmp)
- ==
- (_ctmp='y',islower(_ctmp)?_ctmp-('a'-'A'):_ctmp)
- );
-
- There is two assigment to _ctmp in same expression and there _isn't_
- any sequence point what apply ('==' isn't sequence point).
-
- So it can be executed in follow order:
- _ctmp='x'
- _ctmp='y'
- islower(_ctmp)?_ctmp-('a'-'A'):_ctmp
- islower(_ctmp)?_ctmp-('a'-'A'):_ctmp
-
- Notice that sequrce point (',') after _ctmp='x' didn't apply because
- assigment _ctmp='y' isn't argument of that operation (',').
-
- So error is in macro.
- (Maybe I don't say it clearly ... :-))
-
-
- - K E H
- ( Kari.Hurtta@Helsinki.FI,
- hurtta@cc.Helsinki.FI,
- hurtta@cs.Helsinki.FI,
- HURTTA@FINUH.BITNET
- )
-