This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/25985] New: with optimization integer math fails
- From: "jurka at ejurka dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 26 Jan 2006 23:12:57 -0000
- Subject: [Bug c/25985] New: with optimization integer math fails
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
gcc version 4.2.0 20060121
With optimzation the following code skips the last loop iteration:
#include <stdio.h>
int main(void)
{
int bits = 25;
while (bits) {
printf("bits=%d\n",bits);
if (bits >= 8) {
bits -= 8;
} else {
bits = 0;
}
}
return 0;
}
jurka@fred:~/pg/test$ ~/gcc/42/bin/gcc ip2.c
jurka@fred:~/pg/test$ ./a.out
bits=25
bits=17
bits=9
bits=1
jurka@fred:~/pg/test$ ~/gcc/42/bin/gcc -O ip2.c
jurka@fred:~/pg/test$ ./a.out
bits=25
bits=17
bits=9
jurka@fred:~/pg/test$
--
Summary: with optimization integer math fails
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: critical
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jurka at ejurka dot com
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25985