[LLVMbugs] [Bug 9250] New: -Warray-bounds too noisy on dead code

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Feb 19 01:45:25 PST 2011


           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: unassignedclangbugs at nondot.org
        ReportedBy: edwintorok at gmail.com
                CC: llvmbugs at cs.uiuc.edu

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];

#include <string.h>
#define __BITS_PER_LONG 64
#define _NSIG           64
#define _NSIG_BPW       __BITS_PER_LONG

unsigned long sig[_NSIG_WORDS];

void foo()
    switch (_NSIG_WORDS) {
                memset(&sig[1], -1, sizeof(long)*(_NSIG_WORDS-1));
        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.

More information about the llvm-bugs mailing list