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 middle-end/39154] New: Miscompilation of VLAs in nested parallel regions


The following testcase segfaults at runtime or ICEs (with checking compiler):

extern void abort (void);

int n = 20;

int
main ()
{
  int a[n], b[n][n];

#pragma omp parallel for
    for (int i = 0; i < n; i++)
      {
a[i] = i + 1;
#pragma omp parallel for
for (int j = 0; j < n; j++)
  b[i][j] = a[i];
      }

  for (int i = 0; i < n; i++)
    {
      for (int j = 0; j < n; j++)
if (b[i][j] != i + 1)
  abort ();
      if (a[i] != i + 1)
abort ();
    }

#pragma omp parallel for shared (n, a, b)
    for (int i = 0; i < n; i++)
      {
a[i] = i + 3;
#pragma omp parallel for
for (int j = 0; j < n; j++)
  b[i][j] = a[i];
      }

  for (int i = 0; i < n; i++)
    {
      for (int j = 0; j < n; j++)
if (b[i][j] != i + 3)
  abort ();
      if (a[i] != i + 3)
abort ();
    }

#pragma omp parallel for
    for (int i = 0; i < n; i++)
      {
a[i] = i + 5;
#pragma omp parallel for shared (n, a, b)
for (int j = 0; j < n; j++)
  b[i][j] = a[i];
      }

  for (int i = 0; i < n; i++)
    {
      for (int j = 0; j < n; j++)
if (b[i][j] != i + 5)
  abort ();
      if (a[i] != i + 5)
abort ();
    }

#pragma omp parallel for shared (n, a, b)
    for (int i = 0; i < n; i++)
      {
a[i] = i + 7;
#pragma omp parallel for shared (n, a, b)
for (int j = 0; j < n; j++)
  b[i][j] = a[i];
      }

  for (int i = 0; i < n; i++)
    {
      for (int j = 0; j < n; j++)
if (b[i][j] != i + 7)
  abort ();
      if (a[i] != i + 7)
abort ();
    }
  return 0;
}


-- 
           Summary: Miscompilation of VLAs in nested parallel regions
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: wrong-code, ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: jakub at gcc dot gnu dot org
        ReportedBy: jakub at gcc dot gnu dot org


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


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