https://bugs.llvm.org/show_bug.cgi?id=47606

            Bug ID: 47606
           Summary: OpenMP compile error for lastprivate array member if
                    also firstprivate
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: OpenMP
          Assignee: unassignedclangb...@nondot.org
          Reporter: michael.p.r...@intel.com
                CC: llvm-bugs@lists.llvm.org

If an array member is used in both firstprivate and lastprivate clauses an
error will occur:

<source>:21:56: error: array type 'char [4]' is not assignable

  #pragma omp parallel for firstprivate(y) lastprivate(y)

                                                       ^

But no problem if firstprivate is not used.

#include <stdio.h>
int fails;

struct my_struct {
  char y[4];
  void work();
  void init() { for (int i=0;i<4;++i) y[i] = i; }
  void check() { if (y[3]!=42) fails++; }
  my_struct() {}
};

void my_struct::work() {
  init();
  #pragma omp parallel for lastprivate(y)
  for (int i=0;i<4;++i) {
      y[i] = 42;
  }
  check();

  init();
  #pragma omp parallel for firstprivate(y) lastprivate(y)
  for (int i=0;i<4;++i) {
      y[i] = 42;
  }
  check();
}

int main()
{
  my_struct s;
  s.work();
  if (fails) printf("failed\n");
  else printf("passed\n");
  return fails;
}

https://godbolt.org/z/6E9Po5

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to