[llvm-bugs] [Bug 25042] New: simple use of reference variable gives incorrect result

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Oct 4 01:52:35 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=25042

            Bug ID: 25042
           Summary: simple use of reference variable gives incorrect
                    result
           Product: OpenMP
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Runtime Library
          Assignee: unassignedbugs at nondot.org
          Reporter: llvmbugzilla at jackwasey.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

(See
https://stackoverflow.com/questions/32572966/did-i-misuse-a-reference-variable-in-a-simple-openmp-for-loop-or-is-it-a-clang)

Comparing clang-3.8 head from SVN to clang 3.7 release from SVN, compiled with
libc++ and libomp:

#include <vector>
#include <iostream>
// including or excluding omp makes no difference
#include <omp.h>

void doSomething(std::vector<int> &k) {
#pragma omp for
    for (int i=0; i<2; ++i) {
            std::cout << k.size() << "\n";
    }
}

int main() {
    std::vector<int> v;
    v.push_back(1);

    std::vector<int> &j = v;
    doSomething(j);
    return(0);
}

clang-3.7++ -fopenmp clang-err.cpp
./a.out
18446708892352074976
18446708892352074976


clang-3.8++ -fopenmp clang-err.cpp
./a.out
1
1

-- 
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/20151004/d322f21a/attachment.html>


More information about the llvm-bugs mailing list