[Bug c/36691] New: wrong value left in induction variable

regehr at cs dot utah dot edu gcc-bugzilla@gcc.gnu.org
Tue Jul 1 22:40:00 GMT 2008


This is seen using svn 137327 on Ubuntu Feisty.  I believe 0 is the correct
result.

[regehr@babel tmp35]$ current-gcc -O0 -fwrapv small.c -o small
[regehr@babel tmp35]$ ./small
0
[regehr@babel tmp35]$ current-gcc -O1 -fwrapv small.c -o small
[regehr@babel tmp35]$ ./small
255

[regehr@babel tmp35]$ current-gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../configure --program-prefix=current-
--enable-languages=c,c++ --prefix=/home/regehr
Thread model: posix
gcc version 4.4.0 20080701 (experimental) (GCC) 

[regehr@babel tmp35]$ cat small.c

#include <stdio.h>

unsigned char g_5;

void func_1 (void);
void func_1 (void)
{
  for (g_5 = -7; g_5 >= 4; g_5 -= 5);
}

int main (void)
{
  func_1 ();
  printf ("%d\n", g_5);
  return 0;
}


-- 
           Summary: wrong value left in induction variable
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: regehr at cs dot utah dot edu
 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=36691



More information about the Gcc-bugs mailing list