https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108466
Bug ID: 108466
Summary: inconsistent -Wmaybe-uninitialized warning location
Product: gcc
Version: 12.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: vincent-gcc at vinc17 dot net
Target Milestone: ---
With gcc-12 (Debian 12.2.0-14) 12.2.0, the -Wmaybe-uninitialized warning
location depends on the declared type. This is inconsistent.
To reproduce, consider a tst.c file:
int f(void);
int g(void)
{
T a;
if (f())
a = f();
if (f())
return 0;
else
return a;
}
I get:
$ for i in int long; do echo; echo "Type $i"; gcc-12 -O2 -Wmaybe-uninitialized
-DT=$i -c tst.c; done
Type int
tst.c: In function ‘g’:
tst.c:11:12: warning: ‘a’ may be used uninitialized [-Wmaybe-uninitialized]
11 | return a;
| ^
tst.c:4:5: note: ‘a’ was declared here
4 | T a;
| ^
Type long
tst.c: In function ‘g’:
tst.c:4:5: warning: ‘a’ may be used uninitialized [-Wmaybe-uninitialized]
4 | T a;
| ^