[Bug tree-optimization/105237] Missing uninitialized warning in self-initialization case
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Apr 12 10:06:15 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105237
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2022-04-12
Blocks| |24639
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
If you enable optimization (inlining in this case) the warning is shown:
> gcc-11 -S t2.c -Wall -O
t2.c: In function 'test':
t2.c:2:28: warning: 'n' is used uninitialized [-Wuninitialized]
2 | int negate(int n) { return -n; }
| ^~
t2.c:8:13: note: 'n' was declared here
8 | int n = negate(n); // n used before initialization
| ^
without optimization we are confused by the loop and limited flow analysis.
The
int n = n;
case is a GCC extension to silence uninit diagnostics
Confirmed at -O0.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24639
[Bug 24639] [meta-bug] bug to track all Wuninitialized issues
More information about the Gcc-bugs
mailing list