Except for -O0, all levels of optimization make the same mistake on the
attached files.

Compile them (for example) with:
gcc -O2 sp.c mybyte.c -o sp

On gcc 4.3.1 (vanilla, self-compiled, also applies to the gentoo standard one),
this outputs "123456789abcd" instead of "123456789abcdef" (gcc 4.1.2 for
example).

When removing the fourth line of the loop, it works.

I could reproduce this also on debian.

Just in case you care, the code is ripped out of fefe's libowfat.

Target: i686-pc-linux-gnu
Configured with: ./configure --prefix=/opt/gcc431 --with-mpfr=/opt/gcc431
Thread model: posix
gcc version 4.3.1 (GCC) 
Linux xekskami 2.6.25.10 #8 SMP PREEMPT Thu Jul 17 16:00:00 CEST 2008 i686
Genuine Intel(R) CPU           T2500  @ 2.00GHz GenuineIntel GNU/Linux


-- 
           Summary: optimization breaks code in manually unrolled loop
           Product: gcc
           Version: 4.3.1
            Status: UNCONFIRMED
          Severity: blocker
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: michael+gcc at stapelberg dot de


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

Reply via email to