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: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]


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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to