<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - OpenMP compile error for lastprivate array member if also firstprivate"
   href="https://bugs.llvm.org/show_bug.cgi?id=47606">47606</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>OpenMP compile error for lastprivate array member if also firstprivate
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>OpenMP
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>michael.p.rice@intel.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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;
}

<a href="https://godbolt.org/z/6E9Po5">https://godbolt.org/z/6E9Po5</a></pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>