public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/102801] New: Incorrect -Wmaybe-uninitialized warning/interation for a std::optional only when a nested struct is also present.
@ 2021-10-17 12:47 calin.culianu at bitcoincashnode dot org
  2021-10-17 16:43 ` [Bug c++/102801] Incorrect -Wmaybe-uninitialized warning/interaction " redi at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: calin.culianu at bitcoincashnode dot org @ 2021-10-17 12:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102801

            Bug ID: 102801
           Summary: Incorrect -Wmaybe-uninitialized warning/interation for
                    a std::optional only when a nested struct is also
                    present.
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: calin.culianu at bitcoincashnode dot org
  Target Milestone: ---

Created attachment 51617
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51617&action=edit
Test case where a spurious/incorrect -Wmaybe-uninitialized warning is generated

Hi -- I noticed a regression in GCC 10 and GCC 11 related to `std::optional`. 
The attached file, if compiled with `-O2 -Wall -std=c++17 -c` as options, will
warn incorrectly about uninitialized members on both GCC 10 and GCC 11 (I
haven't tried 9 yet but I think 8 & 9 are ok).

Note that the key element in the below code is the nested `struct Shared`. If
that is omitted, no warnings occur.

Attached code warns erroneously (GCC 10 & 11):

    g++ -O2 -Wall -std=c++17 -c warn3.cpp


Attached code does not warn (nested struct omitted):

    g++ -DNO_WARN -O2 -Wall -std=c++17 -c warn3.cpp

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-09-22 13:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-17 12:47 [Bug c++/102801] New: Incorrect -Wmaybe-uninitialized warning/interation for a std::optional only when a nested struct is also present calin.culianu at bitcoincashnode dot org
2021-10-17 16:43 ` [Bug c++/102801] Incorrect -Wmaybe-uninitialized warning/interaction " redi at gcc dot gnu.org
2021-10-17 20:33 ` egallager at gcc dot gnu.org
2021-10-17 21:59 ` calin.culianu at bitcoincashnode dot org
2022-09-22 13:18 ` [Bug tree-optimization/102801] " rguenth at gcc dot gnu.org
2022-09-22 13:19 ` cvs-commit 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).