<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 - [OpenMP5.0] Wrong behavior when use array sections in map clauses on target and target data constructs"
   href="https://bugs.llvm.org/show_bug.cgi?id=46426">46426</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[OpenMP5.0] Wrong behavior when use array sections in map clauses on target and target data constructs
          </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>sulinna@cn.fujitsu.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>In the examples below, clang has opposite behavior when compile:

These examples are from: 
<a href="https://www.openmp.org/wp-content/uploads/openmp-examples-5.0.0.pdf">https://www.openmp.org/wp-content/uploads/openmp-examples-5.0.0.pdf</a>
4.4 Array Sections in Device Constructs

According to the examples specification in the above url,
Example_array_sections.1.c should throw error,
Example_array_sections.3.c and,
Example_array_sections.4.c should not throw error,
but clang act opposite when compile, details are as below:


test case:
-----------------------------------
Example_array_sections.1.c
void foo ()
{
   int A[30];
#pragma omp target data map( A[0:4] )
{
   /* Cannot map distinct parts of the same array */
   #pragma omp target map( A[7:20] )
   {
      A[2] = 0;
   }
}
}


Example_array_sections.3.c
void foo ()
{
   int A[30], *p;
#pragma omp target data map( A[0:4] )
{
   p = &A[0];
   #pragma omp target map( p[7:20] )
   {
      A[2] = 0;
      p[8] = 0;
   }
}
}

Example_array_sections.4.c
void foo ()
{
   int A[30], *p;
#pragma omp target data map( A[0:10] )
{
   p = &A[0];
   #pragma omp target map( p[3:7] )
   {
      A[2] = 0;
      p[8] = 0;
      A[8] = 1;
   }
}
}

test command:
------------------
# clang --version
clang version 10.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix

# clang -fopenmp-version=50 -fopenmp -S Example_array_sections.1.c
# clang -fopenmp-version=50 -fopenmp -S Example_array_sections.3.c
Example_array_sections.3.c:16:7: error: original storage of expression in data
environment is shared but data environment do not fully contain mapped
expression storage
      A[2] = 0;
      ^
Example_array_sections.3.c:11:30: note: used here
#pragma omp target data map( A[0:4] )
                             ^~~~~~
1 error generated.
]# clang -fopenmp-version=50 -fopenmp -S Example_array_sections.4.c
Example_array_sections.4.c:16:7: error: original storage of expression in data
environment is shared but data environment do not fully contain mapped
expression storage
      A[2] = 0;
      ^
Example_array_sections.4.c:11:30: note: used here
#pragma omp target data map( A[0:10] )
                             ^~~~~~~
1 error generated.</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>