This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/25985] New: with optimization integer math fails


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]