https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127454
Bug ID: 127454
Summary: false-postive -Wuninitialized warning with
-ftrivial-auto-var-init=
Product: gcc
Version: 16.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: arnd at linaro dot org
Target Milestone: ---
Created attachment 65618
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=65618&action=edit
reduced test case
A new spurious -Wuninitialized warning showed up on recent linux kernel builds
In function 'get_tier_idx',
inlined from 'isolate_folios' at mm/vmscan.c:4854:14:
mm/vmscan.c:4812:9: error: 'sp.refaulted' is used uninitialized
[-Werror=uninitialized]
4812 | read_ctrl_pos(lruvec, type, LRU_TIER_MIN, LRU_TIER_MIN, 2,
&sp);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mm/vmscan.c: In function 'isolate_folios':
mm/vmscan.c:4824:25: note: 'sp.refaulted' was declared here
4824 | struct ctrl_pos sp, pv;
| ^~
I had previously tried to address this with a fake initialization, but it came
back and I analyzed further, see the attachment and
https://godbolt.org/z/1q5q4Eh7Y for a reduced test case. I see this happen with
gcc-16.2 and gcc-17.0.0 (20260917).
$ aarch64-linux-gcc -O2 -ftrivial-auto-var-init=zero -Wall -S vmscan.c
In function 'get_tier_idx',
inlined from 'isolate_folios' at vmscan-again.c:99:2:
vmscan.c:73:9: warning: 'sp.refaulted' is used uninitialized [-Wuninitialized]
73 | read_ctrl_pos(lruvec, type, 0, 0, 2, &sp);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vmscan.c: In function 'isolate_folios':
vmscan.c:85:25: note: 'sp.refaulted' was declared here
85 | struct ctrl_pos sp, pv;
| ^~
Marking the read_ctrl_pos() function in the test case or the original source as
either __attribute__((noinline)) or inline avoids the problem, as does any code
change that changes inlining.