public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cuzdav at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug analyzer/107725] New: Spurious warning: use of uninitialized value with std::any
Date: Wed, 16 Nov 2022 20:33:53 +0000	[thread overview]
Message-ID: <bug-107725-4@http.gcc.gnu.org/bugzilla/> (raw)

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

             reply	other threads:[~2022-11-16 20:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-16 20:33 cuzdav at gmail dot com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-107725-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).