http://llvm.org/bugs/show_bug.cgi?id=9250
Summary: -Warray-bounds too noisy on dead code
Product: clang
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected]
When compiling the kernel you get these errors over and over:
include/linux/signal.h:204:10: warning: array index of '1' indexes past the end
of an array (that contains 1 elements) [-Warray-bounds]
case 2: set->sig[1] = 0;
^ ~
In file included from init/main.c:16:
In file included from include/linux/syscalls.h:72:
/home/edwin/builds/linux-2.6/arch/x86/include/asm/signal.h:31:16: note: array
'sig' declared here
unsigned long sig[_NSIG_WORDS];
^
Testcase:
#include <string.h>
#define __BITS_PER_LONG 64
#define _NSIG 64
#define _NSIG_BPW __BITS_PER_LONG
#define _NSIG_WORDS _NSIG /_NSIG_BPW
unsigned long sig[_NSIG_WORDS];
void foo()
{
switch (_NSIG_WORDS) {
default:
memset(&sig[1], -1, sizeof(long)*(_NSIG_WORDS-1));
break;
case 2: sig[1] = -1;
case 1: ;
}
}
There is no out-of-bounds access, because the switch is on a constant,
evaluatable at compile time, and the other cases of the switch are dead code,
and are removed at compile time.
clang should not warn in this case, because the warning is useless.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs