public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* middle-end/9063: invalid compile-time evaluation of tertiary expression
@ 2002-12-27  0:46 geist
  0 siblings, 0 replies; 2+ messages in thread
From: geist @ 2002-12-27  0:46 UTC (permalink / raw)
  To: gcc-gnats


>Number:         9063
>Category:       middle-end
>Synopsis:       invalid compile-time evaluation of tertiary expression
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Dec 27 00:46:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Travis Geiselbrecht
>Release:        gcc version 3.2.2 20021212 (Debian prerelease)
>Organization:
>Environment:
Debian Linux 3.0 testing. x86 pc
>Description:
The following minimal program will reproduce if compiled with 
any levels of optimization. 

Problem:
the expression (100000 + 1 ? 99 : 0) takes on a value of '99',
instead of the expected 100099. A simple addition of parenthesis
to produce (100000 + (1 ? 99 : 0)) produces the proper result.

Not incredibly serious, but I bumped into it and took a while to
figure out. Reproduced on 2.95.4, 3.0.4, and this 3.2.2 pre-release
version in debian. Originally seen on 3.0.4 i386.
>How-To-Repeat:
# 1 "bug.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "bug.c"


int main()
{
        printf("value of expression %d should be %d\n", (100000 + 1 ? 99 : 0), (100000 + (1 ? 99 : 0)));
        return 0;
}
>Fix:
Add parentheses around the tertiary operator.
>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: middle-end/9063: invalid compile-time evaluation of tertiary expression
@ 2002-12-27  3:04 aj
  0 siblings, 0 replies; 2+ messages in thread
From: aj @ 2002-12-27  3:04 UTC (permalink / raw)
  To: aj, gcc-bugs, gcc-prs, geist, nobody

Synopsis: invalid compile-time evaluation of tertiary expression

Responsible-Changed-From-To: unassigned->aj
Responsible-Changed-By: aj
Responsible-Changed-When: Fri Dec 27 03:04:46 2002
Responsible-Changed-Why:
    Taking it.
State-Changed-From-To: open->closed
State-Changed-By: aj
State-Changed-When: Fri Dec 27 03:04:46 2002
State-Changed-Why:
    GCC evaluates the expression correct according to the C operator precedence rules, a '+' binds stronger than the '?'.
    You should fix your code and add the braces.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9063


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-12-27 11:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-27  0:46 middle-end/9063: invalid compile-time evaluation of tertiary expression geist
2002-12-27  3:04 aj

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).