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

Reply via email to