perf: gcc-12: tests/builtin-test.c:242:66: error: array subscript 1 is outside array bounds of 'struct test_suite *[1]' [-Werror=array-bounds] ^

From: Naresh Kamboju
Date: Tue Nov 15 2022 - 07:14:46 EST


You might be aware of the following perf build fails with gcc-12 for
32bit arm and i386.
Whereas gcc-11 builds passed.

Reported-by: Linux Kernel Functional Testing <lkft@xxxxxxxxxx>

Build log:
-----------
CC /home/tuxbuild/.cache/tuxmake/builds/1/build/util/block-info.o
In function '__cmd_test',
inlined from 'cmd_test' at tests/builtin-test.c:522:9:
tests/builtin-test.c:242:66: error: array subscript 1 is outside array
bounds of 'struct test_suite *[1]' [-Werror=array-bounds]
242 | for (k = 0, t = tests[j][k]; tests[j][k]; k++,
t = tests[j][k])
| ^
tests/builtin-test.c:351:9: note: in expansion of macro 'for_each_test'
351 | for_each_test(j, k, t) {
| ^~~~~~~~~~~~~
tests/builtin-test.c: In function 'cmd_test':
tests/builtin-test.c:35:27: note: at offset 4 into object 'arch_tests' of size 4
35 | struct test_suite *__weak arch_tests[] = {
| ^~~~~~~~~~
cc1: all warnings being treated as errors

CC /home/tuxbuild/.cache/tuxmake/builds/1/build/util/expr.o
In function 'parse_events_term__num',
inlined from 'parse_events_multi_pmu_add' at util/parse-events.c:1594:6:
util/parse-events.c:2638:64: error: array subscript 'YYLTYPE[0]' is
partly outside array bounds of 'char[4]' [-Werror=array-bounds]
2638 | .err_term = loc_term ? loc_term->first_column : 0,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
util/parse-events.c: In function 'parse_events_multi_pmu_add':
util/parse-events.c:1579:15: note: object 'config' of size 4
1579 | char *config;
| ^~~~~~
cc1: all warnings being treated as errors

build log link,
https://builds.tuxbuild.com/2HXiqb3LCKg451GckF052odBiPY/

Please refer following links for perf build results comparison between
gcc-11 and gcc-12

https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-6.0.y/build/v6.0.8-191-gf8896c3ebbcf/testrun/13003574/suite/build/test/gcc-11-lkftconfig-perf/history/

https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-6.0.y/build/v6.0.8-191-gf8896c3ebbcf/testrun/13003574/suite/build/test/gcc-12-lkftconfig-perf/history/

--
Linaro LKFT
https://lkft.linaro.org