https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121345
Bug ID: 121345
Summary: [16 Regression] obvious incorrect array-bounds warning
Product: gcc
Version: 14.2.0
Status: UNCONFIRMED
Keywords: needs-bisection, needs-reduction, needs-source
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
While building highway with the current trunk I get:
In file included from /home/apinski/src/highway/hwy/foreach_target.h:362,
from
/home/apinski/src/highway/hwy/tests/foreach_vec_test.cc:18:
/home/apinski/src/highway/hwy/tests/foreach_vec_test.cc: In function ‘void
hwy::N_EMU128::{anonymous}::DoTestAllForGEVectors(const Test&) [with long
unsigned int kMinBits = 64; Test = hwy::N_EMU128::ForGEVectors<64,
TestForGEVectors>]’:
/home/apinski/src/highway/hwy/tests/foreach_vec_test.cc:337:62: error: array
subscript -32 is below array bounds of
‘hwy::N_EMU128::{anonymous}::ForeachVectorTestPerLaneSizeState [16]’
[-Werror=array-bounds=]
337 | &TestForGEVectorsState.per_lane_size_states[lane_size];
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
/home/apinski/src/highway/hwy/tests/foreach_vec_test.cc:35:37: note: while
referencing
‘hwy::N_EMU128::{anonymous}::ForeachVectorTestState::per_lane_size_states’
35 | ForeachVectorTestPerLaneSizeState per_lane_size_states[16];
| ^~~~~~~~~~~~~~~~~~~~
This is obvious wrong as the loop looks like:
for (int lane_size = 1; lane_size <= kMaxSupportedLaneSize; lane_size <<= 1)
{
ForeachVectorTestPerLaneSizeState *per_lane_size_state =
&TestForGEVectorsState.per_lane_size_states[lane_size];
Where kMaxSupportedLaneSize is defined as:
static constexpr int kMaxSupportedLaneSize = HWY_HAVE_INTEGER64 ? 8 : 4;