<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 - firstprivate of declare target variable"
   href="https://bugs.llvm.org/show_bug.cgi?id=49098">49098</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>firstprivate of declare target variable
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>Clang Compiler Support
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>kli@ca.ibm.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The explicit firstprivate clause should be respected on the target construct. 
In this case, clang seems to reference the mapped 'ga' instead of the
firstprivate 'ga'.

#include <stdio.h>

#pragma omp declare target
int ga = 5;
#pragma omp end declare target

int main() {
  ga = 100;

#pragma omp target firstprivate(ga)
  {
    ga += 10;
    printf("on device, ga = %d\n", ga);
  }
  printf("on host, ga = %d\n", ga);
  return 0;
}

Current output:
on device, ga = 15
on host, ga = 100

Expected output:
on device, ga = 110
on host, ga = 100</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>