<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 - Error when mapping a structure and a contained array section"
   href="https://bugs.llvm.org/show_bug.cgi?id=38825">38825</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Error when mapping a structure and a contained array section
          </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>hahnjo@hahnjo.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=20838" name="attach_20838" title="Example code">attachment 20838</a> <a href="attachment.cgi?id=20838&action=edit" title="Example code">[details]</a></span>
Example code

I may be wrong here with my interpretation of the standard. If so, feel free to
close as INVALID.

$ cat structure-pointer.c
#include <stdlib.h>

typedef struct {
  int *ptr;
  int val;
} StructWithPtr;

int main(int argc, char *argv[]) {
  StructWithPtr s;
  s.ptr = malloc(sizeof(int));
  s.ptr[0] = 1;
  s.val = 2;

#pragma omp target map(s, s.ptr[0:1])
  {
    s.val++;
    s.ptr[0]++;
  }

  free(s.ptr);

  return 0;
}

$ clang -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda structure-pointer.c
structure-pointer.c:14:27: error: variable already marked as mapped in current
construct
#pragma omp target map(s, s.ptr[0:1])
                          ^~~~~~~~~~
structure-pointer.c:14:24: note: used here
#pragma omp target map(s, s.ptr[0:1])

1 error generated.

I can't find a restriction in standards newer than OpenMP 4.5 but I remember
some discussion about patterns like this (StructWithPtr my have many more
members that would clutter the map clause if listed explicitly).
In the light of p309:1-17 I think this should be allowed.</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>