https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81714
Bug ID: 81714 Summary: incorrect location for uninitialised variable Product: gcc Version: 7.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: akim.demaille at gmail dot com Target Milestone: --- Hi, This seems to be different from #55874 and #60350, but I might be wrong. The caret-display makes it particularly visible. This affects GCC 4.9, 5.4.0, 6.3.0, and 7.1.1. $ cat /tmp/foo.cc int main() { int i; return i + 42; } $ g++-mp-7 -Wall /tmp/foo.cc /tmp/foo.cc: In function 'int main()': /tmp/foo.cc:4:14: warning: 'i' is used uninitialized in this function [-Wuninitialized] return i + 42; ^~ $ gcc-mp-7 --version gcc-mp-7 (MacPorts gcc7 7-20170622_0) 7.1. Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ g++-mp-6 -Wall /tmp/foo.cc /tmp/foo.cc: In function 'int main()': /tmp/foo.cc:4:14: warning: 'i' is used uninitialized in this function [-Wuninitialized] return i + 42; ^~ $ g++-mp-5 -Wall /tmp/foo.cc /tmp/foo.cc: In function 'int main()': /tmp/foo.cc:4:14: warning: 'i' is used uninitialized in this function [-Wuninitialized] return i + 42; ^ $ g++-mp-4.9 -Wall /tmp/foo.cc /tmp/foo.cc: In function 'int main()': /tmp/foo.cc:4:14: warning: 'i' is used uninitialized in this function [-Wuninitialized] return i + 42; ^ In C mode, GCC is not affected, but the location is not very accurate either. $ cat /tmp/foo.c int main() { int i; return i + 42; } $ gcc-mp-7 -Wall /tmp/foo.c /tmp/foo.c: In function 'main': /tmp/foo.c:4:12: warning: 'i' is used uninitialized in this function [-Wuninitialized] return i + 42; ~~^~~~ It seems somewhat specific to this particular warning. $ cat /tmp/foo.cc int main() { [[deprecated]] int a; return 1 + a; } $ g++-mp-7 -Wall /tmp/foo.cc -std=c++14 /tmp/foo.cc: In function 'int main()': /tmp/foo.cc:5:14: warning: 'a' is deprecated [-Wdeprecated-declarations] return 1 + a; ^ /tmp/foo.cc:4:9: note: declared here int a; ^ /tmp/foo.cc:5:14: warning: 'a' is used uninitialized in this function [-Wuninitialized] return 1 + a; ^ Cheers!