gcc-8: mm/swapfile.c:863:40: error: array subscript 1 is above array bounds of 'struct list_head[1]' [-Werror=array-bounds]

From: Naresh Kamboju
Date: Mon Aug 19 2024 - 04:29:35 EST


The x86 builds failed with gcc-8 due to following build warnings / errors on
Linux next-20240802 to next-20240819.

x86_64 defconfig gcc-8 build failed
x86_64 defconfig gcc-13 build pass

First seen on the next-20240802 tag.

GOOD: next-20240730
BAD: next-20240802

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

Build errors:
--------
mm/swapfile.c: In function 'scan_swap_map_slots.constprop':
mm/swapfile.c:863:40: error: array subscript 1 is above array bounds
of 'struct list_head[1]' [-Werror=array-bounds]
while (!list_empty(&si->frag_clusters[o])) {
~~~~~~~~~~~~~~~~~^~~
mm/swapfile.c:872:43: error: array subscript 1 is above array bounds
of 'struct list_head[1]' [-Werror=array-bounds]
while (!list_empty(&si->nonfull_clusters[o])) {
~~~~~~~~~~~~~~~~~~~~^~~
In file included from include/linux/list.h:5,
from include/linux/wait.h:7,
from include/linux/wait_bit.h:8,
from include/linux/fs.h:6,
from include/linux/highmem.h:5,
from include/linux/bvec.h:10,
from include/linux/blk_types.h:10,
from include/linux/blkdev.h:9,
from mm/swapfile.c:9:
include/linux/list.h:612:18: error: array subscript 1 is above array
bounds of 'struct list_head[1]' [-Werror=array-bounds]
list_entry((ptr)->next, type, member)
^~
include/linux/container_of.h:19:26: note: in definition of macro 'container_of'
void *__mptr = (void *)(ptr); \
^~~
include/linux/list.h:612:2: note: in expansion of macro 'list_entry'
list_entry((ptr)->next, type, member)
^~~~~~~~~~
mm/swapfile.c:873:9: note: in expansion of macro 'list_first_entry'
ci = list_first_entry(&si->nonfull_clusters[o],
^~~~~~~~~~~~~~~~
include/linux/list.h:612:18: error: array subscript 1 is above array
bounds of 'struct list_head[1]' [-Werror=array-bounds]
list_entry((ptr)->next, type, member)
^~
include/linux/container_of.h:19:26: note: in definition of macro 'container_of'
void *__mptr = (void *)(ptr); \
^~~
include/linux/list.h:612:2: note: in expansion of macro 'list_entry'
list_entry((ptr)->next, type, member)
^~~~~~~~~~
mm/swapfile.c:864:9: note: in expansion of macro 'list_first_entry'
ci = list_first_entry(&si->frag_clusters[o],
^~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Steps to reproduce:
-------
# tuxmake --runtime podman --target-arch x86_64 --toolchain gcc-8
--kconfig x86_64_defconfig

Build log link,
------
- https://qa-reports.linaro.org/lkft/linux-next-master/build/next-20240819/testrun/24918869/suite/build/test/gcc-8-x86_64_defconfig/log

metadata:
-----
git describe: next-20240802
git repo: https://gitlab.com/Linaro/lkft/mirrors/next/linux-next
git short_log: f524a5e4dfb7 ("Add linux-next specific files for 20240802")
config: https://storage.tuxsuite.com/public/linaro/lkft/builds/2k6wLr4UFODrd3snUDTPPevXpPY/config
download_url:
https://storage.tuxsuite.com/public/linaro/lkft/builds/2k6wLr4UFODrd3snUDTPPevXpPY/
toolchain: gcc-8
arch: x86_64

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