[gomp] c++ for declarations

Andrew Pinski pinskia@physics.uc.edu
Mon Oct 17 22:21:00 GMT 2005


On Oct 17, 2005, at 6:16 PM, Richard Henderson wrote:

> I think I've found all the right bits to handle
>
> 	for (int i = ...)
>
> properly.  Leastways it handles a couple of valid test cases.
> I've not yet tried feeding it garbage to see if I can crash it.

I think I asked this before but how does OpenMP handle the C99
equivalent of this?
Like:
void abort ();

int check;
int f1() { check |= 1; return 1; }
int f2() { check |= 2; return 11; }
int f3() { check |= 4; return 2; }

int a[12];

int main()
{
   #pragma omp for
   for (int i = f1(); i <= f2(); i += f3())
     a[i] = 1;

   for (int i = 0; i < 12; ++i)
     if (a[i] != (i & 1))
       abort ();
}


Also while you are hacking this code, it seems like you could fix
the long standing bug in that the i does not declared in the
correct scope so the following C++ code is invalid:
void f(int l)
{
   for(int i = 0;i<l;i++)
   {
      int i = 2;
   }
}



More information about the Gcc-patches mailing list