<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - gcc ABI incompatibility when passing llvm::Optional"
href="https://bugs.llvm.org/show_bug.cgi?id=39427">39427</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>gcc ABI incompatibility when passing llvm::Optional
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>7.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>LLVM Codegen
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>tneumann@users.sourceforge.net
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=21034" name="attach_21034" title="ABI demonstration">attachment 21034</a> <a href="attachment.cgi?id=21034&action=edit" title="ABI demonstration">[details]</a></span>
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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>