This for loop
for(unsigned i=object::min(_digits, (int)NATIVE_DIGITS);i<NATIVE_DIGITS;++i)
        inside_digit[i]=0;

generates the following incorrect code.
.L182:
        .loc 12 59 0
        movl    -8(%rbp), %eax
        movq    -24(%rbp), %rdx
        mov     %eax, %eax
        movq    $0, (%rdx,%rax,8)
        .loc 12 58 0
        addl    $1, -8(%rbp)
.L181:
        cmpl    $3, -8(%rbp)
        jbe     .L182
        jmp     .L183

This code always runs the body at least once, which, I think is incorrect.
I'm sorry I cannot include a simple test case to reproduce it, but it is very
hard to trigger and trying to isolate it just makes it go away.


-- 
           Summary: "for" loop wrong code generation
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: face dot mitev at gmail dot com
 GCC build triplet: x86_64 linux gnu
  GCC host triplet: x86_64 linux gnu
GCC target triplet: x86_64 linux gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40111

Reply via email to