frontend bug?

2010-12-29 Thread Alex Turjan
Hi all,
Im compiling the code bellow for x86 with gcc 4.4.3 and 4.5. Is it correct
that at the end of main the value of variable b should have been 4? When 
executing I get value 3. 

#include "stdio.h"
int *ptr;

int inc(void){
(*ptr)++;
return 1;
}

int main (void){
int a, b = 2;
ptr = &b;
b++ +  inc() ;

if(b==4)
printf("correct\n");
else
printf("incorrect %d\n",b);
return 1;
}



  


bug linear loop transforms

2010-03-29 Thread Alex Turjan
Im writing to you regarding a possible bug in linear loop transfor.
The bug can be reproduce by compiling the attached c file with gcc.4.5.0 
(20100204, 20100325) on x86 machine.

The compiler flags that reproduce the error are:
-O2 -fno-inline -fno-tree-ch -ftree-loop-linear

If the compiler is run with:
-O2 -fno-inline -fno-tree-ch -fno-tree-loop-linear 
then the produced code is correct.


  #include 

int test (int n, int *a)
{
  int i, j;

  for (i = 0; i < n; i++)
{
  for (j = 0; j < n; j++)
{
  a[j] = i + n;
}
}


if (a[0] != 31 || i + n - 1 != 31)
   printf("incorrect %d  %d \n", a[0], i+n-1);  

  return 0;
}

int main (void)
{
  int a[16];
  test (16, a);
  return 0;
}