https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90367

            Bug ID: 90367
           Summary: Spurious warning array subscript is above array bounds
           Product: gcc
           Version: 9.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: alexandre.ganea at ubisoft dot com
  Target Milestone: ---

We get what seems like a spurious warning at the following location in LLVM:
https://github.com/llvm/llvm-project/blob/master/llvm/lib/Target/AMDGPU/R600ISelLowering.cpp#L1718

The warning is:
    //    warning: array subscript is above array bounds [-Warray-bounds]
    //    if (NewBldVec[i] == NewBldVec[j]) {
    //        ~~~~~~~~~~~^

This only occurs when compiling with GCC 7.1+ and 9.1/trunk (not with 8), with
-O3 -Warray-bounds

This has been creduce'd to:

class a {
  int b;
  unsigned c;

public:
  bool operator==(a) { return b && c; }
};
class d {
public:
  void e();
};
class f {
  a g(d &) const;
};
a f::g(d &h) const {
  a j[1];
  for (unsigned i = 0;; i++)
    for (; i;)
      if (j[i] == j[0])
        h.e();
}

Reply via email to