public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug preprocessor/16192] New: Bug in expression evaluation when operand is missing
@ 2004-06-25 6:04 gnu at behdad dot org
2004-06-25 6:32 ` [Bug preprocessor/16192] " pinskia at gcc dot gnu dot org
` (12 more replies)
0 siblings, 13 replies; 14+ messages in thread
From: gnu at behdad dot org @ 2004-06-25 6:04 UTC (permalink / raw)
To: gcc-bugs
Seems like there's a bug in evaluating expressions in #if statements where one
of the operands is missing. Seems like a value from the top of the stack is
used instead...
Here is the minimal code that goes wrong:
#if (1 < 2) && ( == 2)
JUNK JUNK JUNK
#endif
and it outputs "JUNK JUNK JUNK" while should not. If you change one of the "2"s
to something else, it doesn't happen; that's why I guess it's just taking the
missing operand from the top of the stack...
Needless to say, something like this fails for the same reason (which was were I
found the bug):
#if (x < 2) && (y == 2)
do something
#endif
--
Summary: Bug in expression evaluation when operand is missing
Product: gcc
Version: 3.3.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: preprocessor
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gnu at behdad dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i386-redhat-linux
GCC host triplet: i386-redhat-linux
GCC target triplet: i386-redhat-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16192
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug preprocessor/16192] Bug in expression evaluation when operand is missing
2004-06-25 6:04 [Bug preprocessor/16192] New: Bug in expression evaluation when operand is missing gnu at behdad dot org
@ 2004-06-25 6:32 ` pinskia at gcc dot gnu dot org
2004-06-25 6:39 ` gnu at behdad dot org
` (11 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-25 6:32 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-06-25 06:04 -------
Nope sorry but you are wrong "(x < 2) && (y == 2)" is defined as one by the C standard.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16192
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug preprocessor/16192] Bug in expression evaluation when operand is missing
2004-06-25 6:04 [Bug preprocessor/16192] New: Bug in expression evaluation when operand is missing gnu at behdad dot org
2004-06-25 6:32 ` [Bug preprocessor/16192] " pinskia at gcc dot gnu dot org
@ 2004-06-25 6:39 ` gnu at behdad dot org
2004-06-25 17:47 ` zack at gcc dot gnu dot org
` (10 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: gnu at behdad dot org @ 2004-06-25 6:39 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From gnu at behdad dot org 2004-06-25 06:35 -------
Would you please enlighten me why it's defined as one?
By the way, I still think there's a bug in gcc somewhere, either in
preprocessor, or in documentation. Because in the texinfo documentation I read:
* Identifiers that are not macros, which are all considered to be the
number zero.
Which immediately results that "(x < 2> && (y == 2)" should fail.
Moreover, I also read:
If EXPRESSION is not correctly formed, GCC issues an error and
treats the conditional as having failed.
Which again means that "(1 < 2) && ( == 2)" should fail.
To my not so humble opinion, these don't all make sense at the same time.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16192
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug preprocessor/16192] Bug in expression evaluation when operand is missing
2004-06-25 6:04 [Bug preprocessor/16192] New: Bug in expression evaluation when operand is missing gnu at behdad dot org
2004-06-25 6:32 ` [Bug preprocessor/16192] " pinskia at gcc dot gnu dot org
2004-06-25 6:39 ` gnu at behdad dot org
@ 2004-06-25 17:47 ` zack at gcc dot gnu dot org
2004-06-25 17:48 ` zack at gcc dot gnu dot org
` (9 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: zack at gcc dot gnu dot org @ 2004-06-25 17:47 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From zack at gcc dot gnu dot org 2004-06-25 17:47 -------
The reporter is correct, gcc is misbehaving here - more by the absence of a
diagnostic than by the precise contents of the output, but it *is* documented to
treat an ill-formed #if as having failed. And I have no idea where you got the
idea that (x < 2) && (y == 2) should succeed, where 'x' and 'y' are both
non-macros - that expands to (0 < 2) && (0 == 2) which is obviously false.
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |accepts-invalid
Last reconfirmed|0000-00-00 00:00:00 |2004-06-25 17:47:09
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16192
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug preprocessor/16192] Bug in expression evaluation when operand is missing
2004-06-25 6:04 [Bug preprocessor/16192] New: Bug in expression evaluation when operand is missing gnu at behdad dot org
` (2 preceding siblings ...)
2004-06-25 17:47 ` zack at gcc dot gnu dot org
@ 2004-06-25 17:48 ` zack at gcc dot gnu dot org
2004-06-25 17:48 ` zack at gcc dot gnu dot org
` (8 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: zack at gcc dot gnu dot org @ 2004-06-25 17:48 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From zack at gcc dot gnu dot org 2004-06-25 17:48 -------
... confirming, assigning to self.
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |zack at gcc dot gnu dot org
|dot org |
Status|UNCONFIRMED |ASSIGNED
Ever Confirmed| |1
Last reconfirmed|2004-06-25 17:47:09 |2004-06-25 17:48:16
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16192
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug preprocessor/16192] Bug in expression evaluation when operand is missing
2004-06-25 6:04 [Bug preprocessor/16192] New: Bug in expression evaluation when operand is missing gnu at behdad dot org
` (3 preceding siblings ...)
2004-06-25 17:48 ` zack at gcc dot gnu dot org
@ 2004-06-25 17:48 ` zack at gcc dot gnu dot org
2004-06-25 17:54 ` zack at gcc dot gnu dot org
` (7 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: zack at gcc dot gnu dot org @ 2004-06-25 17:48 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From zack at gcc dot gnu dot org 2004-06-25 17:47 -------
*growl* Reopening ...
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16192
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug preprocessor/16192] Bug in expression evaluation when operand is missing
2004-06-25 6:04 [Bug preprocessor/16192] New: Bug in expression evaluation when operand is missing gnu at behdad dot org
` (4 preceding siblings ...)
2004-06-25 17:48 ` zack at gcc dot gnu dot org
@ 2004-06-25 17:54 ` zack at gcc dot gnu dot org
2004-06-25 18:24 ` neil at gcc dot gnu dot org
` (6 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: zack at gcc dot gnu dot org @ 2004-06-25 17:54 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From zack at gcc dot gnu dot org 2004-06-25 17:48 -------
It should be noted that I won't have a chance to work on this for some time.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16192
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug preprocessor/16192] Bug in expression evaluation when operand is missing
2004-06-25 6:04 [Bug preprocessor/16192] New: Bug in expression evaluation when operand is missing gnu at behdad dot org
` (5 preceding siblings ...)
2004-06-25 17:54 ` zack at gcc dot gnu dot org
@ 2004-06-25 18:24 ` neil at gcc dot gnu dot org
2004-06-26 18:11 ` gnu at behdad dot org
` (5 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: neil at gcc dot gnu dot org @ 2004-06-25 18:24 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From neil at gcc dot gnu dot org 2004-06-25 17:54 -------
I'll pick this up.
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|zack at gcc dot gnu dot org |neil at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16192
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug preprocessor/16192] Bug in expression evaluation when operand is missing
2004-06-25 6:04 [Bug preprocessor/16192] New: Bug in expression evaluation when operand is missing gnu at behdad dot org
` (6 preceding siblings ...)
2004-06-25 18:24 ` neil at gcc dot gnu dot org
@ 2004-06-26 18:11 ` gnu at behdad dot org
2004-06-28 20:28 ` cvs-commit at gcc dot gnu dot org
` (4 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: gnu at behdad dot org @ 2004-06-26 18:11 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From gnu at behdad dot org 2004-06-26 18:03 -------
A bit of misinformation from my side. "(x < 2) && (y == 2)" indeed works as
accepted if x and y are non-macros. But the ill-formed case "(1 < 2) && ( ==
2)" should still fail.
More information, "(2 == )" fails with error. "( == 2)" fails with no error.
"(1< 2) && (2 == )" fails with error, and "(1 < 2) && ( == 2)" does not fail.
In theory all of these four should fail with error.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16192
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug preprocessor/16192] Bug in expression evaluation when operand is missing
2004-06-25 6:04 [Bug preprocessor/16192] New: Bug in expression evaluation when operand is missing gnu at behdad dot org
` (7 preceding siblings ...)
2004-06-26 18:11 ` gnu at behdad dot org
@ 2004-06-28 20:28 ` cvs-commit at gcc dot gnu dot org
2004-06-28 20:41 ` [Bug preprocessor/16192] [3.5 only] " pinskia at gcc dot gnu dot org
` (3 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-06-28 20:28 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-06-28 20:28 -------
Subject: Bug 16192
CVSROOT: /cvs/gcc
Module name: gcc
Branch: gcc-3_4-branch
Changes by: neil@gcc.gnu.org 2004-06-28 20:28:07
Modified files:
gcc : cppinit.c cppexp.c
gcc/doc : cpp.texi cppopts.texi
gcc/testsuite/gcc.dg/cpp: if-mop.c
Added files:
gcc/testsuite/gcc.dg/cpp/trad: comment-3.c
Log message:
PR preprocessor/16192
PR preprocessor/15913
PR preprocessor/15572
* cppexp.c (_cpp_parse_expr): Handle remaining cases where an
expression is missing.
* cppinit.c (post_options): Traditional cpp doesn't do // comments.
* doc/cpp.texi: Don't document what we do for ill-formed expressions.
* doc/cppopts.texi: Clarify processing of command-line defines.
testsuite:
* gcc.dg/cpp/if-mop.c: Two new testcases.
* gcc.dg/cpp/trad/comment-3.c: New.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cppinit.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.297.6.5&r2=1.297.6.6
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cppexp.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.144.6.1&r2=1.144.6.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/doc/cpp.texi.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.65.4.2&r2=1.65.4.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/doc/cppopts.texi.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.28.4.3&r2=1.28.4.4
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/cpp/if-mop.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3&r2=1.3.54.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/cpp/trad/comment-3.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16192
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug preprocessor/16192] [3.5 only] Bug in expression evaluation when operand is missing
2004-06-25 6:04 [Bug preprocessor/16192] New: Bug in expression evaluation when operand is missing gnu at behdad dot org
` (8 preceding siblings ...)
2004-06-28 20:28 ` cvs-commit at gcc dot gnu dot org
@ 2004-06-28 20:41 ` pinskia at gcc dot gnu dot org
2004-07-04 12:57 ` cvs-commit at gcc dot gnu dot org
` (2 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-28 20:41 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-06-28 20:41 -------
Fixed in 3.4.1 and Neil is testing for 3.5.0 but is having bootstrap problems even without the patch.
--
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |3.4.1
Summary|Bug in expression evaluation|[3.5 only] Bug in expression
|when operand is missing |evaluation when operand is
| |missing
Target Milestone|--- |3.5.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16192
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug preprocessor/16192] [3.5 only] Bug in expression evaluation when operand is missing
2004-06-25 6:04 [Bug preprocessor/16192] New: Bug in expression evaluation when operand is missing gnu at behdad dot org
` (9 preceding siblings ...)
2004-06-28 20:41 ` [Bug preprocessor/16192] [3.5 only] " pinskia at gcc dot gnu dot org
@ 2004-07-04 12:57 ` cvs-commit at gcc dot gnu dot org
2004-07-04 12:58 ` neil at gcc dot gnu dot org
2004-09-13 17:43 ` [Bug preprocessor/16192] [4.0 Regression] " giovannibajo at libero dot it
12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-07-04 12:57 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-07-04 12:57 -------
Subject: Bug 16192
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: neil@gcc.gnu.org 2004-07-04 12:57:51
Modified files:
gcc : ChangeLog
libcpp : ChangeLog expr.c init.c
gcc/doc : cpp.texi cppopts.texi
gcc/testsuite : ChangeLog
gcc/testsuite/gcc.dg/cpp: if-mop.c
Added files:
gcc/testsuite/gcc.dg/cpp/trad: comment-3.c
Log message:
* doc/cpp.texi: Don't document what we do for ill-formed expressions.
* doc/cppopts.texi: Clarify processing of command-line defines.
libcpp:
PR preprocessor/16192
PR preprocessor/15913
PR preprocessor/15572
* expr.c (_cpp_parse_expr): Handle remaining cases where an
expression is missing.
* init.c (post_options): Traditional cpp doesn't do // comments.
testsuite:
* gcc.dg/cpp/if-mop.c: Two new testcases.
* gcc.dg/cpp/trad/comment-3.c: New.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.4281&r2=2.4282
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libcpp/ChangeLog.diff?cvsroot=gcc&r1=1.16&r2=1.17
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libcpp/expr.c.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libcpp/init.c.diff?cvsroot=gcc&r1=1.2&r2=1.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/doc/cpp.texi.diff?cvsroot=gcc&r1=1.69&r2=1.70
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/doc/cppopts.texi.diff?cvsroot=gcc&r1=1.34&r2=1.35
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3936&r2=1.3937
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/cpp/if-mop.c.diff?cvsroot=gcc&r1=1.3&r2=1.4
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/cpp/trad/comment-3.c.diff?cvsroot=gcc&r1=1.1&r2=1.2
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16192
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug preprocessor/16192] [3.5 only] Bug in expression evaluation when operand is missing
2004-06-25 6:04 [Bug preprocessor/16192] New: Bug in expression evaluation when operand is missing gnu at behdad dot org
` (10 preceding siblings ...)
2004-07-04 12:57 ` cvs-commit at gcc dot gnu dot org
@ 2004-07-04 12:58 ` neil at gcc dot gnu dot org
2004-09-13 17:43 ` [Bug preprocessor/16192] [4.0 Regression] " giovannibajo at libero dot it
12 siblings, 0 replies; 14+ messages in thread
From: neil at gcc dot gnu dot org @ 2004-07-04 12:58 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From neil at gcc dot gnu dot org 2004-07-04 12:58 -------
Fixed in 3.4 and 3.5.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16192
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug preprocessor/16192] [4.0 Regression] Bug in expression evaluation when operand is missing
2004-06-25 6:04 [Bug preprocessor/16192] New: Bug in expression evaluation when operand is missing gnu at behdad dot org
` (11 preceding siblings ...)
2004-07-04 12:58 ` neil at gcc dot gnu dot org
@ 2004-09-13 17:43 ` giovannibajo at libero dot it
12 siblings, 0 replies; 14+ messages in thread
From: giovannibajo at libero dot it @ 2004-09-13 17:43 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Summary|[3.5 only] Bug in expression|[4.0 Regression] Bug in
|evaluation when operand is |expression evaluation when
|missing |operand is missing
Target Milestone|4.0.0 |3.4.1
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16192
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2004-09-13 17:43 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-25 6:04 [Bug preprocessor/16192] New: Bug in expression evaluation when operand is missing gnu at behdad dot org
2004-06-25 6:32 ` [Bug preprocessor/16192] " pinskia at gcc dot gnu dot org
2004-06-25 6:39 ` gnu at behdad dot org
2004-06-25 17:47 ` zack at gcc dot gnu dot org
2004-06-25 17:48 ` zack at gcc dot gnu dot org
2004-06-25 17:48 ` zack at gcc dot gnu dot org
2004-06-25 17:54 ` zack at gcc dot gnu dot org
2004-06-25 18:24 ` neil at gcc dot gnu dot org
2004-06-26 18:11 ` gnu at behdad dot org
2004-06-28 20:28 ` cvs-commit at gcc dot gnu dot org
2004-06-28 20:41 ` [Bug preprocessor/16192] [3.5 only] " pinskia at gcc dot gnu dot org
2004-07-04 12:57 ` cvs-commit at gcc dot gnu dot org
2004-07-04 12:58 ` neil at gcc dot gnu dot org
2004-09-13 17:43 ` [Bug preprocessor/16192] [4.0 Regression] " giovannibajo at libero dot it
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).