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

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).