[Bug middle-end/63477] [6/7/8 Regression] Bogus warning with -O3 -Warray-bounds: array subscript is above array bounds

2019-05-06 Thread alexandre.ganea at ubisoft dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63477

Alexandre Ganea  changed:

   What|Removed |Added

 CC||alexandre.ganea at ubisoft dot 
com

--- Comment #4 from Alexandre Ganea  ---
Hi,

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;; i++)
for (; i;)
  if (j[i] == j[0])
h.e();
}

Could you please confirm the issue?
Thank you!

[Bug c++/90367] New: Spurious warning array subscript is above array bounds

2019-05-06 Thread alexandre.ganea at ubisoft dot com
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();
}

[Bug c++/90367] Spurious warning array subscript is above array bounds

2019-05-06 Thread alexandre.ganea at ubisoft dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90367

--- Comment #2 from Alexandre Ganea  ---
Slighly modified version with zero-init variables still shows the warning:
https://godbolt.org/z/Mht3uF

Andrew: you say "I think you reduced it too much". I simply used "gcc file.cpp
-O3 -Warray-bounds | grep -i '\-Warray-bounds'" as an interestingness test.
Would you suggest something else, I could try it again?

[Bug c++/90367] Spurious warning array subscript is above array bounds

2019-05-06 Thread alexandre.ganea at ubisoft dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90367

--- Comment #3 from Alexandre Ganea  ---
Another strange thing, if I change 'SDValue NewBldVec[4];' to 'SDValue
NewBldVec[14];' in the code where the issue occurs, the warning goes away. If I
set it to 13 or less, the warning is still there.

https://github.com/llvm/llvm-project/blob/master/llvm/lib/Target/AMDGPU/R600ISelLowering.cpp#L1694

[Bug c++/90367] Spurious warning array subscript is above array bounds

2019-05-06 Thread alexandre.ganea at ubisoft dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90367

--- Comment #5 from Alexandre Ganea  ---
Created attachment 46306
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46306&action=edit
preprocessed source

Please see attachement.

[Bug c++/90367] Spurious warning array subscript is above array bounds

2019-05-06 Thread alexandre.ganea at ubisoft dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90367

--- Comment #6 from Alexandre Ganea  ---
...and the command-line:

/usr/bin/c++  -DGTEST_HAS_RTTI=0 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib/Target/AMDGPU
-I/mnt/f/svn/llvm/lib/Target/AMDGPU -Iinclude -I/mnt/f/svn/llvm/include -fPIC
-fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -Wextra
-Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -Wno-long-long
-Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-noexcept-type
-Wdelete-non-virtual-dtor -Wno-comment -Wno-unused-parameter -Wno-type-limits
-Wno-cast-qual -Wno-deprecated-declarations -Wno-empty-body -Wno-overflow
-Wno-unused-variable -Wno-switch -fdiagnostics-color -ffunction-sections
-fdata-sections -O3 -DNDEBUG-fno-exceptions -fno-rtti -c
/mnt/f/svn/llvm/lib/Target/AMDGPU/R600ISelLowering_3.cpp

[Bug c++/90367] Spurious warning array subscript is above array bounds

2019-05-06 Thread alexandre.ganea at ubisoft dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90367

--- Comment #7 from Alexandre Ganea  ---
I used the following GCC version for preprocessing/compiling:

$ /usr/bin/c++ --version
c++ (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0