[llvm-bugs] [Bug 39427] New: gcc ABI incompatibility when passing llvm::Optional
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Oct 24 23:05:46 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=39427
Bug ID: 39427
Summary: gcc ABI incompatibility when passing llvm::Optional
Product: clang
Version: 7.0
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: LLVM Codegen
Assignee: unassignedclangbugs at nondot.org
Reporter: tneumann at users.sourceforge.net
CC: llvm-bugs at lists.llvm.org
Created attachment 21034
--> https://bugs.llvm.org/attachment.cgi?id=21034&action=edit
ABI demonstration
Calling llvm::ConstantExpr::getGetElementPtr crashes when LLVM 7 is compiled
with gcc 8.2 and the caller is compiled with clang 7.
The reason is an ABI incompatibility: clang wants to pass the
llvm::Optional<unsigned> parameter by value (i.e., as a single i64), while gcc
expects the value to be passed by reference.
I have attached a simple test program that demonstrates the problem explicitly,
regardless how the underlying LLVM was compiled. (It still uses the LLVM 7
headers, but the problem is triggered purely in the example code here).
To reproduce, compile and run the attached program like this:
clang++-7 -c -opart1.o foo.cpp `llvm-config-7 --cxxflags`
g++ -c -opart2.cpp -DPART2 foo.cpp `llvm-config-7 --cxxflags`
clang++-7 -ofoo part1.o part2.o `llvm-config-7 --cxxflags`
./foo
This leads to a crash. Using either g++ or clang++ for both files is fine, but
mixing them leads to a crash. By inspecting the assembler code we can see that
clang++ passes by value, and g++ passes by reference.
--
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/20181025/5eb11c21/attachment.html>
More information about the llvm-bugs
mailing list