<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 - Bug when using VLA and OpenMP"
href="https://bugs.llvm.org/show_bug.cgi?id=36409">36409</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Bug when using VLA and OpenMP
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>5.0
</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>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>maarten.bosmans@vortech.nl
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>The address of a VLA is not captured correctly in a OpenMP parallel region.
At least 4.0 and 5.0 are affected.
The following example shows the problem (compiled with clang -std=c99 -fopenmp)
#include <stdlib.h>
#include <stdio.h>
int main() {
int size = 5;
float *P1 = malloc(100 * sizeof(float));
float (*P2)[size] = (void*) P1;
printf("TEST1 P1=%p P2=%p\n", (void*) P1, (void*) P2);
# pragma omp parallel num_threads(2)
{
printf("TEST2 P1=%p P2=%p\n", (void*) P1, (void*) P2);
}
return 0;
}
Output is something like:
TEST1 P1=0xc2db60 P2=0xc2db60
TEST2 P1=0xc2db60 P2=0x7ffc183b1e78
TEST2 P1=0xc2db60 P2=0x7ffc183b1e78
Expected output would be 6 times the same pointer value.
The correct output can be seen when compiling with gcc or icc, and with clang
when the size is set to a literal 5 in the declaration of P2 or when the
firstprivate(P2) clause is added to the omp pragma.</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>