<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 - MS ABI incompatibility when calling virtual function with single bool parameter"
href="https://bugs.llvm.org/show_bug.cgi?id=39962">39962</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>MS ABI incompatibility when calling virtual function with single bool parameter
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>6.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</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>cerickson@curedev.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=21213" name="attach_21213" title="Repro case showing the incorrect behavior">attachment 21213</a> <a href="attachment.cgi?id=21213&action=edit" title="Repro case showing the incorrect behavior">[details]</a></span>
Repro case showing the incorrect behavior
When calling a clang-compiled virtual function from an msvc-compiled function,
the virtual function's single bool parameter is passed incorrectly (an argument
of `false` becomes `true`).
This only happens when optimizations are applied to the msvc-compiled source
file (starting with /O1).
This bug appears in the wild when passing a std::function by value across a
compiler boundary, as in this case here:
<a href="https://stackoverflow.com/questions/50388773/stdfunction-clang-6-0-msvc-10-0017134-12-possible-abi-bug-or-required-c">https://stackoverflow.com/questions/50388773/stdfunction-clang-6-0-msvc-10-0017134-12-possible-abi-bug-or-required-c</a>
std::function ends up performing a double delete as a result of misinterpreting
a bool argument in this fashion.
I've attached a repro case that can be run on an X64 Windows machine with VS
2017 installed.
The expected output of the test case:
[msc] Calling EnsureFalse(false)
[clang] Inside EnsureFalse(false)
The actual output:
[msc] Calling EnsureFalse(false)
[clang] Inside EnsureFalse(true)</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>