public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug analyzer/107725] New: Spurious warning: use of uninitialized value with std::any
@ 2022-11-16 20:33 cuzdav at gmail dot com
2022-11-16 20:40 ` [Bug analyzer/107725] " cuzdav at gmail dot com
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: cuzdav at gmail dot com @ 2022-11-16 20:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107725
Bug ID: 107725
Summary: Spurious warning: use of uninitialized value with
std::any
Product: gcc
Version: 12.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: analyzer
Assignee: dmalcolm at gcc dot gnu.org
Reporter: cuzdav at gmail dot com
Target Milestone: ---
Created attachment 53914
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53914&action=edit
preprocessed code
With the analyzer (-fanalyzer), this built cleanly with GCC10 and GCC11, but
starting with GCC 12 (still occurring in trunk) in either C++17 or c++20 mode,
I see this warning (x86 linux):
<source>:4:13: warning: use of uninitialized value '<unknown>' [CWE-457]
[-Wanalyzer-use-of-uninitialized-value]
4 | return {};
| ^
'std::any create()': events 1-2
|
| 3 | std::any create() {
| | ^
| | |
| | (1) region created on stack here
| 4 | return {};
| | ~
| | |
| | (2) use of uninitialized value '<unknown>' here
|
Compiler returned: 0
This is the code in its entirety:
#include <any>
std::any create() {
return {};
}
https://godbolt.org/z/TWPcaW4Kn
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug analyzer/107725] Spurious warning: use of uninitialized value with std::any
2022-11-16 20:33 [Bug analyzer/107725] New: Spurious warning: use of uninitialized value with std::any cuzdav at gmail dot com
@ 2022-11-16 20:40 ` cuzdav at gmail dot com
2022-11-16 21:10 ` dmalcolm at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: cuzdav at gmail dot com @ 2022-11-16 20:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107725
--- Comment #1 from Chris Uzdavinis <cuzdav at gmail dot com> ---
I get a similar warning with this code. Unsure if it's the same underlying
issue. Also does not warn with g++10 or g++11, but does with newer versions.
#include <sstream>
#include <string>
std::string create() {
std::ostringstream oss;
return oss.str();
}
https://godbolt.org/z/cz66zhKn5
<source>:6:20: warning: use of uninitialized value '<unknown>' [CWE-457]
[-Wanalyzer-use-of-uninitialized-value]
6 | return oss.str();
| ^
'std::string create()': events 1-2
|
| 4 | std::string create() {
| | ^
| | |
| | (1) region created on stack here
| 5 | std::ostringstream oss;
| 6 | return oss.str();
| | ~
| | |
| | (2) use of uninitialized value '<unknown>' here
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug analyzer/107725] Spurious warning: use of uninitialized value with std::any
2022-11-16 20:33 [Bug analyzer/107725] New: Spurious warning: use of uninitialized value with std::any cuzdav at gmail dot com
2022-11-16 20:40 ` [Bug analyzer/107725] " cuzdav at gmail dot com
@ 2022-11-16 21:10 ` dmalcolm at gcc dot gnu.org
2022-11-16 21:10 ` dmalcolm at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2022-11-16 21:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107725
David Malcolm <dmalcolm at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Blocks| |97110
--- Comment #2 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
C++ isn't supported by the analyzer yet. I hope to address this in GCC 14, but
it's not going to give useful results on C++ before then.
Sorry about this.
Marked as NEW and added to the analyzer-c++ tracker, to tackle in GCC 14.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97110
[Bug 97110] [meta-bug] tracker bug for supporting C++ in -fanalyzer
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug analyzer/107725] Spurious warning: use of uninitialized value with std::any
2022-11-16 20:33 [Bug analyzer/107725] New: Spurious warning: use of uninitialized value with std::any cuzdav at gmail dot com
2022-11-16 20:40 ` [Bug analyzer/107725] " cuzdav at gmail dot com
2022-11-16 21:10 ` dmalcolm at gcc dot gnu.org
@ 2022-11-16 21:10 ` dmalcolm at gcc dot gnu.org
2022-11-16 21:48 ` cuzdav at gmail dot com
2022-11-16 22:16 ` dmalcolm at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2022-11-16 21:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107725
David Malcolm <dmalcolm at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2022-11-16
Ever confirmed|0 |1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug analyzer/107725] Spurious warning: use of uninitialized value with std::any
2022-11-16 20:33 [Bug analyzer/107725] New: Spurious warning: use of uninitialized value with std::any cuzdav at gmail dot com
` (2 preceding siblings ...)
2022-11-16 21:10 ` dmalcolm at gcc dot gnu.org
@ 2022-11-16 21:48 ` cuzdav at gmail dot com
2022-11-16 22:16 ` dmalcolm at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cuzdav at gmail dot com @ 2022-11-16 21:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107725
--- Comment #3 from Chris Uzdavinis <cuzdav at gmail dot com> ---
Ah, sorry I didn't realize that. Its use was suggested by Jason Turner in his
most recent C++ Weekly so I started to give it a try. Perhaps there will be an
influx of such premature reports since it was put on the radar.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug analyzer/107725] Spurious warning: use of uninitialized value with std::any
2022-11-16 20:33 [Bug analyzer/107725] New: Spurious warning: use of uninitialized value with std::any cuzdav at gmail dot com
` (3 preceding siblings ...)
2022-11-16 21:48 ` cuzdav at gmail dot com
@ 2022-11-16 22:16 ` dmalcolm at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2022-11-16 22:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107725
--- Comment #4 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Aha thanks: presumably "Ep 350 - The Right Way to Write C++ Code in 2022"?
I'm watching it now.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-11-16 22:16 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-16 20:33 [Bug analyzer/107725] New: Spurious warning: use of uninitialized value with std::any cuzdav at gmail dot com
2022-11-16 20:40 ` [Bug analyzer/107725] " cuzdav at gmail dot com
2022-11-16 21:10 ` dmalcolm at gcc dot gnu.org
2022-11-16 21:10 ` dmalcolm at gcc dot gnu.org
2022-11-16 21:48 ` cuzdav at gmail dot com
2022-11-16 22:16 ` dmalcolm at gcc dot gnu.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).