<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 - False positive: array values filled with over-aligned size are treated as garbage or undefined"
href="https://bugs.llvm.org/show_bug.cgi?id=37665">37665</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>False positive: array values filled with over-aligned size are treated as garbage or undefined
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</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>Static Analyzer
</td>
</tr>
<tr>
<th>Assignee</th>
<td>dcoughlin@apple.com
</td>
</tr>
<tr>
<th>Reporter</th>
<td>arseny.kapoulkine@gmail.com
</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=20386" name="attach_20386" title="minimal repro">attachment 20386</a> <a href="attachment.cgi?id=20386&action=edit" title="minimal repro">[details]</a></span>
minimal repro
Given a function, that takes size_t count and fills a local array with count
values and then reads count values from the array, everything works well.
When instead we use the following expression to align count upwards:
size_t aligned_count = (count + 15) & ~15;
And fill aligned_count elements instead, static analyzer thinks that elements
read from the array could be uninitialized. This doesn't seem to be due to
count possibly overflowing since removing "& ~15" removes the error.
Adding assert(aligned_count >= count); doesn't seem to fix this :(
Reproducer online: <a href="https://godbolt.org/g/55vJQ6">https://godbolt.org/g/55vJQ6</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>