[llvm-bugs] [Bug 36409] New: Bug when using VLA and OpenMP
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Feb 16 05:20:46 PST 2018
https://bugs.llvm.org/show_bug.cgi?id=36409
Bug ID: 36409
Summary: Bug when using VLA and OpenMP
Product: clang
Version: 5.0
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: maarten.bosmans at vortech.nl
CC: llvm-bugs at lists.llvm.org
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.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180216/2c229c19/attachment.html>
More information about the llvm-bugs
mailing list