* [Bug c/110368] Incorrect "is used uninitialized" warning message
2023-06-22 17:27 [Bug c/110368] New: Incorrect "is used uninitialized" warning message clugstj at gmail dot com
@ 2023-06-22 17:29 ` clugstj at gmail dot com
2023-06-22 17:31 ` pinskia at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: clugstj at gmail dot com @ 2023-06-22 17:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110368
--- Comment #1 from Jon Clugston <clugstj at gmail dot com> ---
Created attachment 55385
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55385&action=edit
gcc -v
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c/110368] Incorrect "is used uninitialized" warning message
2023-06-22 17:27 [Bug c/110368] New: Incorrect "is used uninitialized" warning message clugstj at gmail dot com
2023-06-22 17:29 ` [Bug c/110368] " clugstj at gmail dot com
@ 2023-06-22 17:31 ` pinskia at gcc dot gnu.org
2023-06-22 17:32 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-22 17:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110368
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The warning is due to the code having undefined behavior in it. The code stores
in a variable as int but reads part of it via short type. That is an aliasing
violation.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c/110368] Incorrect "is used uninitialized" warning message
2023-06-22 17:27 [Bug c/110368] New: Incorrect "is used uninitialized" warning message clugstj at gmail dot com
2023-06-22 17:29 ` [Bug c/110368] " clugstj at gmail dot com
2023-06-22 17:31 ` pinskia at gcc dot gnu.org
@ 2023-06-22 17:32 ` pinskia at gcc dot gnu.org
2023-06-22 17:35 ` pinskia at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-22 17:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110368
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|UNCONFIRMED |RESOLVED
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
As explained undefined code.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c/110368] Incorrect "is used uninitialized" warning message
2023-06-22 17:27 [Bug c/110368] New: Incorrect "is used uninitialized" warning message clugstj at gmail dot com
` (2 preceding siblings ...)
2023-06-22 17:32 ` pinskia at gcc dot gnu.org
@ 2023-06-22 17:35 ` pinskia at gcc dot gnu.org
2023-06-22 17:37 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-22 17:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110368
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The code can fixed using memcpy
Replace:
c += *data_16++
With:
unsigned tmp;
memcpy(&tmp, data_16, sizeof(tmp));
data_16++;
c += tmp;
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c/110368] Incorrect "is used uninitialized" warning message
2023-06-22 17:27 [Bug c/110368] New: Incorrect "is used uninitialized" warning message clugstj at gmail dot com
` (3 preceding siblings ...)
2023-06-22 17:35 ` pinskia at gcc dot gnu.org
@ 2023-06-22 17:37 ` pinskia at gcc dot gnu.org
2023-10-05 16:19 ` clugstj at gmail dot com
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-22 17:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110368
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #4)
> The code can fixed using memcpy
> Replace:
> c += *data_16++
>
> With:
> unsigned tmp;
> memcpy(&tmp, data_16, sizeof(tmp));
> data_16++;
> c += tmp;
Small typo, the type of tmp should have been `unsigned short`.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c/110368] Incorrect "is used uninitialized" warning message
2023-06-22 17:27 [Bug c/110368] New: Incorrect "is used uninitialized" warning message clugstj at gmail dot com
` (4 preceding siblings ...)
2023-06-22 17:37 ` pinskia at gcc dot gnu.org
@ 2023-10-05 16:19 ` clugstj at gmail dot com
2023-10-06 15:51 ` sjames at gcc dot gnu.org
2023-10-07 6:36 ` xry111 at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: clugstj at gmail dot com @ 2023-10-05 16:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110368
--- Comment #6 from Jon Clugston <clugstj at gmail dot com> ---
So, "undefined behavior" gives the compiler license to output any warning it
wants?
The warning message is utterly wrong and completely misleading.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c/110368] Incorrect "is used uninitialized" warning message
2023-06-22 17:27 [Bug c/110368] New: Incorrect "is used uninitialized" warning message clugstj at gmail dot com
` (5 preceding siblings ...)
2023-10-05 16:19 ` clugstj at gmail dot com
@ 2023-10-06 15:51 ` sjames at gcc dot gnu.org
2023-10-07 6:36 ` xry111 at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: sjames at gcc dot gnu.org @ 2023-10-06 15:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110368
--- Comment #7 from Sam James <sjames at gcc dot gnu.org> ---
That said, I suppose we should do better here with -Wstrict-aliasing. No level
detects it.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c/110368] Incorrect "is used uninitialized" warning message
2023-06-22 17:27 [Bug c/110368] New: Incorrect "is used uninitialized" warning message clugstj at gmail dot com
` (6 preceding siblings ...)
2023-10-06 15:51 ` sjames at gcc dot gnu.org
@ 2023-10-07 6:36 ` xry111 at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-10-07 6:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110368
Xi Ruoyao <xry111 at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |xry111 at gcc dot gnu.org
--- Comment #8 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
(In reply to Sam James from comment #7)
> That said, I suppose we should do better here with -Wstrict-aliasing. No
> level detects it.
I think it's very difficult to make -Wstrict-aliasing really useful. A
sanitizer at runtime would be much more useful but the develop of such a
sanitizer seems stalled
(https://discourse.llvm.org/t/reviving-typesanitizer-a-sanitizer-to-catch-type-based-aliasing-violations/).
For now we can only compare the output with or without -fno-strict-aliasing.
And we are already saying "try -fno-strict-aliasing" in the bug report
guidance.
^ permalink raw reply [flat|nested] 9+ messages in thread