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: unassignedclangb...@nondot.org
          Reporter: maarten.bosm...@vortech.nl
                CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to