https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113224
Bug ID: 113224
Summary: Warning "is used uninitialized" raised for an
initialized variable
Product: gcc
Version: 13.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: gandalf at winds dot org
Target Milestone: ---
Target: x86_64-pc-linux-gnu
In an attempt to convert a float value bytewise to an integer, this function
returns the following unexpected GCC warnings at optimization level -O2 and -O3
on x86_64:
unsigned int myfunc() {
float _f=2.5;
unsigned int *_x=(unsigned int *)&_f;
return *_x;
}
gcc -O2 -Wall test12.c -c
test12.c: In function 'myfunc':
test12.c:4:10: warning: '_f' is used uninitialized
test12.c:2:9: note: '_f' declared here
It compiles correctly, at least. The warning goes away when
-fno-strict-aliasing is applied.