[LLVMbugs] [Bug 11007] New: Regression: -Warray-bounds doesn't catch errors it used to catch

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Sep 25 12:37:20 PDT 2011


http://llvm.org/bugs/show_bug.cgi?id=11007

           Summary: Regression: -Warray-bounds doesn't catch errors it
                    used to catch
           Product: clang
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: oneill+llvmbugs at cs.hmc.edu
                CC: llvmbugs at cs.uiuc.edu


Created an attachment (id=7350)
 --> (http://llvm.org/bugs/attachment.cgi?id=7350)
Trivial array-out-of-bounds code.

It seems like -Warray-bounds is broken.

Here's clang-2.9

unix% ~/llvm-2.9/bin/clang -Wall -Wextra -Warray-bounds -Wuninitialized -o oob
oob.c
oob.c:6:28: warning: array index of '1000' indexes past the end of an array
      (that contains 5 elements) [-Warray-bounds]
  printf("a[1000] = %f\n", a[1000]);
                           ^ ~~~~
oob.c:5:3: note: array 'a' declared here
  double a[5];
  ^
1 warning generated.
unix%

And here's the trunk,

unix% ~/llvm-r140466/bin/clang -Wall -Wextra -Warray-bounds -Wuninitialized -o
oob oob.c
unix% 

It seems that the warning got lost somewhere between revision 135862 and 137888
(since I happen to have those versions built an kicking around still).

unix% ~/llvm-r135862/bin/clang -Wall -Wextra -Warray-bounds -Wuninitialized -o
oob oob.c
oob.c:6:28: warning: array index of '1000' indexes past the end of an array
      (that contains 5 elements) [-Warray-bounds]
  printf("a[1000] = %f\n", a[1000]);
                           ^ ~~~~
oob.c:5:3: note: array 'a' declared here
  double a[5];
  ^
1 warning generated.
unix% ~/llvm-r137888/bin/clang -Wall -Wextra -Warray-bounds -Wuninitialized -o
oob oob.c
unix% 

Also, note that none of these warn about using an uninitialized value.

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