<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 - -Warray-bounds warning with asm goto in impossible switch cases"
href="https://bugs.llvm.org/show_bug.cgi?id=51682">51682</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>-Warray-bounds warning with asm goto in impossible switch cases
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</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>C
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>natechancellor@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=25206" name="attach_25206" title="False positive -Warray-bounds reproducer">attachment 25206</a> <a href="attachment.cgi?id=25206&action=edit" title="False positive -Warray-bounds reproducer">[details]</a></span>
False positive -Warray-bounds reproducer
A piece of code in the Linux kernel triggers -Warray-bounds when it appears
that it should not [1]. Attached is a small reproducer, which has been derived
from arch/powerpc/kernel/signal_32.c [2].
$ clang -fsyntax-only -Weverything warray-bounds.c
warray-bounds.c:12:27: warning: array index 3 is past the end of the array
(which contains 1 element) [-Warray-bounds]
__asm__ goto("" : : "r"(oldset->sig[3] >> 32) : : failed);
^ ~
warray-bounds.c:4:2: note: array 'sig' declared here
unsigned long sig[NSIG_WORDS];
^
warray-bounds.c:16:27: warning: array index 2 is past the end of the array
(which contains 1 element) [-Warray-bounds]
__asm__ goto("" : : "r"(oldset->sig[2] >> 32) : : failed);
^ ~
warray-bounds.c:4:2: note: array 'sig' declared here
unsigned long sig[NSIG_WORDS];
^
warray-bounds.c:20:27: warning: array index 1 is past the end of the array
(which contains 1 element) [-Warray-bounds]
__asm__ goto("" : : "r"(oldset->sig[1] >> 32) : : failed);
^ ~
warray-bounds.c:4:2: note: array 'sig' declared here
unsigned long sig[NSIG_WORDS];
^
3 warnings generated.
$ gcc -fsyntax-only -Wall -Wextra -Wpedantic warray-bounds.c
This appears similar to PR36115 but the second function appears to do the right
thing and not warn so I do not think that it is the same situation.
[1]: <a href="https://lore.kernel.org/r/YS0nJtNDCwfbaubZ@Ryzen-9-3900X.localdomain/">https://lore.kernel.org/r/YS0nJtNDCwfbaubZ@Ryzen-9-3900X.localdomain/</a>
[2]:
<a href="https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/powerpc/kernel/signal_32.c?h=v5.14">https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/powerpc/kernel/signal_32.c?h=v5.14</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>