https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120208
Bug ID: 120208
Summary: -Wmaybe-uninitialized with -O2 obviously wrong
Product: gcc
Version: 14.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: stsp at users dot sourceforge.net
Target Milestone: ---
Created attachment 61391
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61391&action=edit
test case
Attached is a preprocessed source.
gcc -O2 -Wall -xc regcomp.E -c -fpreprocessed -o regcomp.o
In function ‘findmust’,
inlined from ‘regcomp’ at regcomp.E:1261:2:
regcomp.E:2178:21: warning: ‘scan’ may be used uninitialized
[-Wmaybe-uninitialized]
2178 | while (((s = *scan++)&0x7c000000) != (2<<(26)) )
| ~~~~^~
regcomp.E: In function ‘regcomp’:
regcomp.E:2124:7: note: ‘scan’ was declared here
2124 | sop *scan;
Now if we look into the source,
then we see this:
scan = start;
for (i = g->mlen; i > 0; i--) {
while (((s = *scan++)&0x7c000000) != (2<<(26)) )
So it was initialized just 2 lines above.