public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "calin.culianu at bitcoincashnode dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/102801] New: Incorrect -Wmaybe-uninitialized warning/interation for a std::optional only when a nested struct is also present.
Date: Sun, 17 Oct 2021 12:47:50 +0000	[thread overview]
Message-ID: <bug-102801-4@http.gcc.gnu.org/bugzilla/> (raw)

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

             reply	other threads:[~2021-10-17 12:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-17 12:47 calin.culianu at bitcoincashnode dot org [this message]
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

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