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/16309] New: different behavior in lvalue assignment in -O0 & -O2


Compiling with -O2 and -O0 the following code i obtain different
result with gcc version > 3.2 ( i tryed 3.3.3,3.3.4)

unsigned char dest[10],source[10]={1,2,3,4,5,6,7,8,9,10};

int main(void)
{
  int i = 1;
  int step = 1;

  while (i < 8)
    dest[i] = source[(i++*step) % 7];


  for(i=0; i < 8; i++)
    printf("%02x ",dest[i]);

  printf("\n");


  i=1;

  while (i < 8)
    {
      dest[i] = source[(i*step) % 7];
      i++;
    }

  for(i=0; i < 8; i++)
    printf("%02x ",dest[i]);

  printf("\n");

  return(i+dest[6]);
}

the difference is how dest[i] is addressed via the index i.

-- 
           Summary: different behavior in lvalue assignment in -O0 & -O2
           Product: gcc
           Version: 3.3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: nakkore at libero dot it
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: Reading specs from /usr/lib/gcc-lib/i686-pc-linux-
                    gnu/3.3.3/spec
  GCC host triplet: i386
GCC target triplet: i386


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


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