[Bug analyzer/107725] Spurious warning: use of uninitialized value with std::any

2022-11-16 Thread dmalcolm at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107725

--- Comment #4 from David Malcolm  ---
Aha thanks: presumably "Ep 350 - The Right Way to Write C++ Code in 2022"?  
I'm watching it now.

[Bug analyzer/107725] Spurious warning: use of uninitialized value with std::any

2022-11-16 Thread cuzdav at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107725

--- Comment #3 from Chris Uzdavinis  ---
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.

[Bug analyzer/107725] Spurious warning: use of uninitialized value with std::any

2022-11-16 Thread dmalcolm at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107725

David Malcolm  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2022-11-16
 Ever confirmed|0   |1

[Bug analyzer/107725] Spurious warning: use of uninitialized value with std::any

2022-11-16 Thread dmalcolm at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107725

David Malcolm  changed:

   What|Removed |Added

 Blocks||97110

--- Comment #2 from David Malcolm  ---
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

[Bug analyzer/107725] Spurious warning: use of uninitialized value with std::any

2022-11-16 Thread cuzdav at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107725

--- Comment #1 from Chris Uzdavinis  ---
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 
#include 

std::string create() {
std::ostringstream oss;
return oss.str();
}


https://godbolt.org/z/cz66zhKn5

:6:20: warning: use of uninitialized value '' [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 '' here