[llvm-bugs] [Bug 30490] New: clang-3.9: OpenMP reduction with reference value crashes Clang

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Sep 22 08:05:45 PDT 2016


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

            Bug ID: 30490
           Summary: clang-3.9: OpenMP reduction with reference value
                    crashes Clang
           Product: OpenMP
           Version: unspecified
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: Clang Compiler Support
          Assignee: unassignedclangbugs at nondot.org
          Reporter: xucheng at me.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Created attachment 17334
  --> https://llvm.org/bugs/attachment.cgi?id=17334&action=edit
bug code + report

A minimal example to reproduce the problem:
```cpp
#include <cstdio>

void sum(int* input, int N, int& result)
{
    result = 0;
#pragma omp parallel for reduction(+ : result)
    for (int i = 0; i < N; i++) {
        result += input[i];
    }
}

int main()
{
    int result;
    int input[3] = { 0, 1, 2 };
    sum(input, 3, result);
    printf("result=%d\n", result);
    return 0;
}
```

Compiling with LLVM 3.9, it outputs:
```
$ /usr/local/opt/llvm/bin/clang++ -fopenmp -L/usr/local/opt/llvm/lib/
llvm-3.9-bug.cpp
Stack dump:
0.    Program arguments: /usr/local/Cellar/llvm/3.9.0/bin/clang-3.9 -cc1
-triple x86_64-apple-macosx10.12.0 -Wdeprecated-objc-isa-usage
-Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free
-disable-llvm-verifier -discard-value-names -main-file-name llvm-3.9-bug.cpp
-mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim
-masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 274.1
-dwarf-column-info -debugger-tuning=lldb -resource-dir
/usr/local/Cellar/llvm/3.9.0/bin/../lib/clang/3.9.0 -stdlib=libc++
-fdeprecated-macro -fdebug-compilation-dir /tmp -ferror-limit 19
-fmessage-length 100 -fopenmp -stack-protector 1 -fblocks
-fobjc-runtime=macosx-10.12.0 -fencode-extended-block-signature
-fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option
-fcolor-diagnostics -o
/var/folders/0b/tjnr_tzx3b3ckmf2s5260gx00000gp/T/llvm-3-c3d3cd.o -x c++
llvm-3.9-bug.cpp
1.    llvm-3.9-bug.cpp:6:47: at annotation token
2.    llvm-3.9-bug.cpp:4:1: parsing function body 'sum'
3.    llvm-3.9-bug.cpp:4:1: in compound statement ('{}')
clang-3.9: error: unable to execute command: Segmentation fault: 11
clang-3.9: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.9.0 (tags/RELEASE_390/final)
Target: x86_64-apple-darwin16.0.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin
clang-3.9: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and
associated run script.
clang-3.9: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-3.9: note: diagnostic msg:
/var/folders/0b/tjnr_tzx3b3ckmf2s5260gx00000gp/T/llvm-3-39db7d.cpp
clang-3.9: note: diagnostic msg:
/var/folders/0b/tjnr_tzx3b3ckmf2s5260gx00000gp/T/llvm-3-39db7d.sh
clang-3.9: note: diagnostic msg:

********************
```

Changing `int &result` to `int result`, the compilation will be success.

Also, FYI, the same code has no problem to be compiled under GCC as shown in
below:
```
$ gcc-6 -fopenmp llvm-3.9-bug.cpp && ./a.out
result=3
```

Full reports are in the attachment.

-- 
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/20160922/ca0959e8/attachment-0001.html>


More information about the llvm-bugs mailing list