<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 - bool parameter is tested as a 32-bit value, should use only the low byte"
href="https://bugs.llvm.org/show_bug.cgi?id=36886">36886</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>bool parameter is tested as a 32-bit value, should use only the low byte
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</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>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>dmajor@mozilla.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>__declspec(noinline) int fn(bool b) { return b ? 0x42 : 0; }
At -O1 and higher on 64-bit Windows, clang-cl generates code that goes like:
test!fn:
00000001`40001000 85c9 test ecx,ecx
00000001`40001002 b842000000 mov eax,42h
00000001`40001007 0f44c1 cmove eax,ecx
00000001`4000100a c3 ret
where the function tests the full 32-bit value of ecx. This can end up taking
the wrong code path if the caller only filled in the low byte of the register
and the upper bytes are garbage. (For what it's worth, MSVC looks at only the
low byte in this case.)
clang version 7.0.0 (trunk 328367)
Reduced from
<a href="https://searchfox.org/mozilla-central/rev/de5c4376b89c3603341d226a65acea12f8851ec5/netwerk/base/nsUDPSocket.cpp#571">https://searchfox.org/mozilla-central/rev/de5c4376b89c3603341d226a65acea12f8851ec5/netwerk/base/nsUDPSocket.cpp#571</a></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>