<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 - Variable used by task is not made firstprivate by default as suggested by the Spec (end of section 2.15.1.1)"
   href="https://bugs.llvm.org/show_bug.cgi?id=39422">39422</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Variable used by task is not made firstprivate by default as suggested by the Spec (end of section 2.15.1.1)
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>OpenMP
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </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>Clang Compiler Support
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>simone.at@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>a.bataev@hotmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=21032" name="attach_21032" title="segfaults for missing firstprivate">attachment 21032</a> <a href="attachment.cgi?id=21032&action=edit" title="segfaults for missing firstprivate">[details]</a></span>
segfaults for missing firstprivate

The attached test that uses task inside a parallel region fails for segfaults.
The issue seems to be that the variable P is not being made threadprivate as it
is suggested in the Specification at the end of the section 2.15.1.1.

----------------------------FROM THE SPEC----------------------------
- In a task generating construct, if no default clause is present, a variable
for which the data-sharing attribute is not determined by the rules above and
that in the enclosing context is determined to be shared by all implicit tasks
bound to the current team is shared.
- In a task generating construct, if no default clause is present, a variable
for which the data-sharing attribute is not determined by the rules above is
firstprivate
----------------------------FROM THE SPEC----------------------------

The segfaults happens with both Clang 6.0 and 7.0. Compiling the test with GCC
and Intel Compiler does not result in an issue.

The behavior is also broken for private variables that have definitely no
dynamic storage duration (just to exclude that the pointer is the
problem):

int main() {

#pragma omp parallel num_threads(NUM_THREADS)
   {
     int P = omp_get_thread_num();
     printf("%d: %d\n", omp_get_thread_num(), P);

#pragma omp task
     {
#pragma omp critical
       {
         printf("%d: %d\n", omp_get_thread_num(), P);
         P += 10;
       }
     }
#pragma omp barrier
     printf("%d: %d\n", omp_get_thread_num(), P);
   }
}

For firstprivate, the change of P should have no effect outside of the task,
but running the tests P gets affected also outside the task.</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>