<html>
<head>
<base href="https://llvm.org/bugs/" />
</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 --- - [msan] False positive on icmp sgt (trunc %x), -1"
href="https://llvm.org/bugs/show_bug.cgi?id=24561">24561</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[msan] False positive on icmp sgt (trunc %x), -1
</td>
</tr>
<tr>
<th>Product</th>
<td>compiler-rt
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</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>compiler-rt
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>eugeni.stepanov@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>$ cat 1.cc
#include <stdio.h>
struct A {
bool c1 : 7;
bool c8 : 1;
bool c9 : 1;
A();
};
__attribute__((noinline)) A::A() : c8(false) {}
int main() {
A* a = new A();
if (a->c8)
printf("zz\n");
return 0;
}
$ clang++ 1.cc -O2 -fsanitize=memory && ./a.out
WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x7f8dd5a8712c in main 1.cc:15:7
...
Bitcode for the "if" instruction:
%10 = bitcast i8* %call to i16*
%bf.load = load i16, i16* %10, align 1
%11 = trunc i16 %bf.load to i8
%bf.cast = icmp sgt i8 %11, -1
br i1 %bf.cast, label %if.end, label %if.then
MSan instrumentation:
%bf.load = load i16, i16* %1, align 1
%4 = ptrtoint i16* %1 to i64
%5 = and i64 %4, -70368744177665
%6 = inttoptr i64 %5 to i16*
%_msld = load i16, i16* %6, align 1
%_msprop = trunc i16 %_msld to i8
%7 = trunc i16 %bf.load to i8
<span class="quote">>>> BUG</span >
%8 = trunc i8 %_msprop to i1
%bf.cast = icmp sgt i8 %7, -1
<<<
%_mscmp2 = icmp ne i1 %8, false
br i1 %_mscmp2, label %9, label %10, !prof !1</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>