[LLVMbugs] [Bug 17383] New: clang -Warray-bounds doesn't warn in some instances (where XLC and gcc do)

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Sep 26 14:33:50 PDT 2013


            Bug ID: 17383
           Summary: clang -Warray-bounds doesn't warn in some instances
                    (where XLC and gcc do)
           Product: new-bugs
           Version: trunk
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: sean at rogue-research.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 11283
  --> http://llvm.org/bugs/attachment.cgi?id=11283&action=edit
repro case

Test case attached:

#include <iostream>

class MyClass
  int ivar[2];

  void Method()
  // This warns.
  this->ivar[2] = 0;

  // This warns.
  int foo[2];
  foo[2] = 0;

  // This warns.
  int tmp = this->ivar[2]; (void)tmp;

  std::cout << this->ivar[2];

clang trunk r191092 fails to warn on the last case, where the "<<" is involved.

This is a reduced test case from VTK, which is built daily by many compilers.

XLC warns:
"/.../VTK/Rendering/Core/vtkTextMapper.cxx", line 101.53: 1540-2907 (W) The
subscript 2 is out of range. The valid range is 0 to 1.


and gcc warns:
In member function 'virtual void vtkTextMapper::PrintSelf(std::ostream&,
warning: array subscript is above array bounds [-Warray-bounds]


You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130926/977a3704/attachment.html>

More information about the llvm-bugs mailing list