[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


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

            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
{
private:
  int ivar[2];

public:
  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;

  // FAILS TO WARN
  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.

<http://open.cdash.org/viewBuildError.php?type=1&buildid=3040120>


and gcc warns:
/home/kitware/Dashboards/MyTests/VTK-nightly-release-src/Rendering/Core/vtkTextMapper.cxx:
In member function 'virtual void vtkTextMapper::PrintSelf(std::ostream&,
vtkIndent)':
/home/kitware/Dashboards/MyTests/VTK-nightly-release-src/Rendering/Core/vtkTextMapper.cxx:101:54:
warning: array subscript is above array bounds [-Warray-bounds]

<http://open.cdash.org/viewBuildError.php?type=1&buildid=3040230>

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