public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* optimization/6790: conditional expression as assignment lhs evaluated incorrectly
@ 2002-05-23 17:26 horsh
0 siblings, 0 replies; 2+ messages in thread
From: horsh @ 2002-05-23 17:26 UTC (permalink / raw)
To: gcc-gnats
>Number: 6790
>Category: optimization
>Synopsis: conditional expression as assignment lhs evaluated incorrectly
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: ice-on-legal-code
>Submitter-Id: net
>Arrival-Date: Thu May 23 17:26:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: papahorsh
>Release: 2.95.3 20010315 (SuSE), 3.1
>Organization:
>Environment:
Reading specs from /usr/lib/gcc-lib/i486-suse-linux/2.95.3/specs
gcc version 2.95.3 20010315 (SuSE)
or
Reading specs from /pkg/gnu/lib/gcc-lib/sparc-sun-solaris2.8/3.1/specs
Configured with: ../configure --prefix=/pkg/gnu --enable-languages=c++,f77
Thread model: posix
gcc version 3.1
>Description:
The following four little pieces should give identical
results:
$gcc test.c; ./a.out
-2, -2, -2 , -2, 0, -2
-2, -2, -2 , -2, 0, -2
-2, -2, -2 , -2, 0, -2
-2, -2, -2 , -2, 0, -2
but they dont:
gcc test.c; ./a.out
-2, -2, -2 , -2, 0, -2
-4, -2, -2 , -2, 0, -2
-2, -2, -2 , -2, 0, -2
-2, -2, -2 , -2, 0, -2
$cat test.c
void
main(void) {
int a, b, c, x, y, z, A, B, C, X, Y, Z;
a=-2; b=-2; c=-2; x=-2; y=-2; z=-2;
(y -= b);
(c ? a : b) += (x ? y : z);
printf("%d, %d, %d , %d, %d, %d\n", a, b, c, x, y, z);
/*------------------------------------------------------------------*/
a=-2; b=-2; c=-2; x=-2; y=-2; z=-2;
(
(y -= b) ?
(c ? a : b) :
(c ? a : b) ) += (x ? y : z);
printf("%d, %d, %d , %d, %d, %d\n", a, b, c, x, y, z);
/*------------------------------------------------------------------*/
a=-2; b=-2; c=-2; x=-2; y=-2; z=-2;
(
(y -= b) ?
((c ? a : b) += (x ? y : z)) :
((c ? a : b) += (x ? y : z)) );
printf("%d, %d, %d , %d, %d, %d\n", a, b, c, x, y, z);
/*------------------------------------------------------------------*/
a=-2; b=-2; c=-2; x=-2; y=-2; z=-2;
(
(y -= b) ?
((c ? (a += (x ? y : z)) : (b += (x ? y : z)))) :
((c ? (a += (x ? y : z)) : (b += (x ? y : z)))) );
printf("%d, %d, %d , %d, %d, %d\n", a, b, c, x, y, z);
}
>How-To-Repeat:
just compile and run:
$gcc test.c; ./a.out
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: optimization/6790: conditional expression as assignment lhs evaluated incorrectly
@ 2002-05-23 21:10 rth
0 siblings, 0 replies; 2+ messages in thread
From: rth @ 2002-05-23 21:10 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, horsh, nobody
Synopsis: conditional expression as assignment lhs evaluated incorrectly
State-Changed-From-To: open->closed
State-Changed-By: rth
State-Changed-When: Thu May 23 21:10:51 2002
State-Changed-Why:
Not a bug. There is no sequence point across an assignment operator.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6790
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-05-24 4:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-23 17:26 optimization/6790: conditional expression as assignment lhs evaluated incorrectly horsh
2002-05-23 21:10 rth
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).