From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5890 invoked by alias); 26 Jan 2006 23:13:00 -0000 Received: (qmail 5876 invoked by uid 48); 26 Jan 2006 23:12:57 -0000 Date: Thu, 26 Jan 2006 23:13:00 -0000 Subject: [Bug c/25985] New: with optimization integer math fails X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "jurka at ejurka dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2006-01/txt/msg02929.txt.bz2 List-Id: gcc version 4.2.0 20060121 With optimzation the following code skips the last loop iteration: #include 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