public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/113224] New: Warning "is used uninitialized" raised for an initialized variable
@ 2024-01-03 20:11 gandalf at winds dot org
2024-01-03 20:39 ` [Bug tree-optimization/113224] " pinskia at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: gandalf at winds dot org @ 2024-01-03 20:11 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/113224] Warning "is used uninitialized" raised for an initialized variable
2024-01-03 20:11 [Bug tree-optimization/113224] New: Warning "is used uninitialized" raised for an initialized variable gandalf at winds dot org
@ 2024-01-03 20:39 ` pinskia at gcc dot gnu.org
2024-01-03 20:42 ` pinskia at gcc dot gnu.org
2024-01-03 20:43 ` gandalf at winds dot org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-03 20:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113224
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Resolution|--- |INVALID
Status|UNCONFIRMED |RESOLVED
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This code is undefined for violating C/C++ aliasing rules.
The warning is because of the undefinedness of the code.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/113224] Warning "is used uninitialized" raised for an initialized variable
2024-01-03 20:11 [Bug tree-optimization/113224] New: Warning "is used uninitialized" raised for an initialized variable gandalf at winds dot org
2024-01-03 20:39 ` [Bug tree-optimization/113224] " pinskia at gcc dot gnu.org
@ 2024-01-03 20:42 ` pinskia at gcc dot gnu.org
2024-01-03 20:43 ` gandalf at winds dot org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-03 20:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113224
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
>In an attempt to convert a float value bytewise to an integer,
You should use memcpy instead (or an union which itself a GCC extension).
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/113224] Warning "is used uninitialized" raised for an initialized variable
2024-01-03 20:11 [Bug tree-optimization/113224] New: Warning "is used uninitialized" raised for an initialized variable gandalf at winds dot org
2024-01-03 20:39 ` [Bug tree-optimization/113224] " pinskia at gcc dot gnu.org
2024-01-03 20:42 ` pinskia at gcc dot gnu.org
@ 2024-01-03 20:43 ` gandalf at winds dot org
2 siblings, 0 replies; 4+ messages in thread
From: gandalf at winds dot org @ 2024-01-03 20:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113224
--- Comment #3 from gandalf at winds dot org ---
Thank you for the suggestion. I'll try the union.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-01-03 20:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-03 20:11 [Bug tree-optimization/113224] New: Warning "is used uninitialized" raised for an initialized variable gandalf at winds dot org
2024-01-03 20:39 ` [Bug tree-optimization/113224] " pinskia at gcc dot gnu.org
2024-01-03 20:42 ` pinskia at gcc dot gnu.org
2024-01-03 20:43 ` gandalf at winds dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).