public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: optimization/2847: GCC 2.96 with -O2 incorrectly compile if(var==0) break; else printf("test\n"); inside a while
@ 2001-08-13 16:03 rodrigc
0 siblings, 0 replies; 2+ messages in thread
From: rodrigc @ 2001-08-13 16:03 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, nobody, rodrigc, yannick.koehler
Synopsis: GCC 2.96 with -O2 incorrectly compile if(var==0) break; else printf("test\n"); inside a while
State-Changed-From-To: open->closed
State-Changed-By: rodrigc
State-Changed-When: Mon Aug 13 16:03:16 2001
State-Changed-Why:
Works with: gcc version 3.0.1 20010813
Please contact Mandrake with issues regarding the
compiler supplied with Mandrake Linux.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=2847&database=gcc
^ permalink raw reply [flat|nested] 2+ messages in thread
* optimization/2847: GCC 2.96 with -O2 incorrectly compile if(var==0) break; else printf("test\n"); inside a while
@ 2001-05-16 13:26 yannick.koehler
0 siblings, 0 replies; 2+ messages in thread
From: yannick.koehler @ 2001-05-16 13:26 UTC (permalink / raw)
To: gcc-gnats
>Number: 2847
>Category: optimization
>Synopsis: GCC 2.96 with -O2 incorrectly compile if(var==0) break; else printf("test\n"); inside a while
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Wed May 16 13:26:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Yannick Koehler
>Release: gcc version 2.96 20000731 (Linux-Mandrake 8.0 2.96-0.48mdk)
>Organization:
>Environment:
Mandrake 7.2 updated to Mandrake 8.0
>Description:
I'm compiling this code with this command:
gcc -O2 ./bug.c
running ./a.out doesn't output the word "Wonderful!" as it should...
CODE:
#include <stdio.h>
int main(int argc, char *argv)
{
int iNbr = 1;
int test = 0;
while(test == 0) {
printf("iNbr = %d\n", iNbr);
if (iNbr == 0)
break;
else {
printf("Wonderful\n");
iNbr--;
}
test = 1;
}
return 0;
}
Instead if display nothing. But if I replace the condition if (iNbr==0) with if (0) things work. Even optimized that code should print Wonderful.
This code works with -O1 -O3 and with 2.95.3
>How-To-Repeat:
take the attachment and compile with 2.96 and option -O2 or -Os
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="bug.c"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="bug.c"
I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgbWFpbihpbnQgYXJnYywgY2hhciAqYXJndikKewoJaW50
IGlOYnIgPSAxOwoJaW50IHRlc3QgPSAwOwoJd2hpbGUodGVzdCA9PSAwKSB7CgkJcHJpbnRmKCJp
TmJyID0gJWRcbiIsIGlOYnIpOwoJCWlmIChpTmJyID09IDApCgkJCWJyZWFrOwoJCWVsc2UgewoJ
CQlwcmludGYoIldvbmRlcmZ1bFxuIik7CgkJCWlOYnItLTsKCQl9CQkJCgkJdGVzdCA9IDE7Cgl9
CglyZXR1cm4gMDsKfQo=
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-08-13 16:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-13 16:03 optimization/2847: GCC 2.96 with -O2 incorrectly compile if(var==0) break; else printf("test\n"); inside a while rodrigc
-- strict thread matches above, loose matches on Subject: below --
2001-05-16 13:26 yannick.koehler
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).