[Bug c++/81901] New: false-positive -Warray-bounds
webrown.cpp at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sun Aug 20 19:48:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81901
Bug ID: 81901
Summary: false-positive -Warray-bounds
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: vermaelen.wouter at gmail dot com
CC: webrown.cpp at gmail dot com
Target Milestone: ---
CC: webrown.cpp at gmail dot com
When switching from gcc-6 to gcc-7 my application triggers some new compiler
warnings (with -Wall). I believe these warnings are false-positives. But I
don't see an easy way to work around them. I also tested with a gcc-8 snapshot
(2017/08/19) and the problem persists.
I managed to reduce my program to the following:
int a[8];
extern void f2();
void f() {
for (int i = 0x3F; i >= 0x10; --i) {
switch (i & 0xF0) {
case 0x00:
if ((i & 0x0F) < 8) a[i] = 0;
break;
case 0x10:
f2();
}
}
}
Compile with
g++ -O2 -Wall test.cpp
warning: array subscript is above array bounds [-Warray-bounds]
More information about the Gcc-bugs
mailing list