<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 - use_device_addr always returns a NULL pointer"
   href="https://bugs.llvm.org/show_bug.cgi?id=48184">48184</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>use_device_addr always returns a NULL pointer
          </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>Runtime Library
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>csdaley@lbl.gov
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The use_device_addr clause appears to be implemented incorrectly
(use_device_ptr clause works as expected). The LLVM OpenMP trace shows
use_device_addr returns a NULL pointer `Libomptarget --> Returning device
pointer 0x0000000000000000` before the test program segfaults on the fprintf
statement.

```
#include <stdio.h>
#include <stdlib.h>
#define N 100
int main()
{
  double *x = malloc(N*sizeof(double));
#pragma omp target enter data map(alloc:x[:N])

#pragma omp target data use_device_ptr(x)
  {
    fprintf(stderr, "ptr=%p\n", (void*)x);
  }
#pragma omp target data use_device_addr(x)
  {
    fprintf(stderr, "addr=%p\n", (void*)x); // Fail
  }
  return 0;
}
```

I tested with Clang/LLVM commit bae9aedb341c5f4eceafba2ee1fec7c05d842c97 (12
Nov 2020)</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>