[Bug middle-end/25261] [gomp] Nested function calls in #pragma omp parallel blocks

jakub at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Mon Sep 11 15:47:00 GMT 2006



------- Comment #4 from jakub at gcc dot gnu dot org  2006-09-11 15:46 -------
Furthermore, I have no idea what would:
extern void abort (void);

int
baz (int (*bar) (void))
{
  return bar ();
}

void
foo (int *j)
{
  int i = 5;
  int (*fn) (void);
  int bar (void) { return i + 1; }
  fn = bar;
  if (bar (fn) != 6)
    #pragma omp atomic
      ++j;
#pragma omp sections private (i)
  {
    #pragma omp section
    {
      i = 6;
      if (baz (fn) != 7)
        #pragma omp atomic
          ++*j;
    }
    #pragma omp section
    {
      if (baz (fn) != 6)
        #pragma omp atomic
          ++*j;
    }
  }
}

int
main (void)
{
  int j = 0;
#pragma omp parallel num_threads (2)
  foo (&j);
  if (j)
    abort ();
  return 0;
}
be supposed to do.  Do other openmp compilers support nested C functions?  If
so,
what they are doing here?  It would be easy to say that e.g. all non-local vars
in nested functions are implicitly shared (i.e. we always reference the
original
parent function's variables, not any remapped ones).  But can we do the same in
Fortran where nested functions are part of the standard?


-- 


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



More information about the Gcc-bugs mailing list