This is the mail archive of the 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/33498] New: Optimizer (-O2) may convert a normal loop to infinite

gcc-4.2.0 and gcc-4.2.1 cannot compile properly this function if -O2 is

It generates an infinite loop :(

No problem for previous version (gcc-4.1.2 is OK)

$ cat bug.c
void table_init(int *value)
        int i;
        int val = 0x03020100;

        for (i = 0; i < 256/4; i++) {
                value[i] = val;
                val += 0x04040404;

$ gcc -O2 -S bug.c
$ cat bug.s
        .file   "bug.c"
        .p2align 4,,15
.globl table_init
        .type   table_init, @function
        pushl   %ebp
        movl    $50462976, %edx
        movl    %esp, %ebp
        movl    $1, %eax
        movl    8(%ebp), %ecx
        .p2align 4,,7
        movl    %edx, -4(%ecx,%eax,4)
        addl    $67372036, %edx
        addl    $1, %eax
        jmp     .L2
        .size   table_init, .-table_init
        .ident  "GCC: (GNU) 4.2.1"
        .section        .note.GNU-stack,"",@progbits

           Summary: Optimizer (-O2) may convert a normal loop to infinite
           Product: gcc
           Version: 4.2.1
            Status: UNCONFIRMED
          Severity: critical
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dada1 at cosmosbay dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu

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