public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "ed at catmur dot uk" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107206] New: Bogus -Wuninitialized in std::optional Date: Mon, 10 Oct 2022 23:14:09 +0000 [thread overview] Message-ID: <bug-107206-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107206 Bug ID: 107206 Summary: Bogus -Wuninitialized in std::optional Product: gcc Version: 12.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ed at catmur dot uk Target Milestone: --- Since 12, at -std=c++17 -O -Wuninitialized: #include <optional> struct X { X() = default; X(X const& r) : i(r.i) {} int i; }; struct Y { Y() : x() {} X x; std::optional<int> o; }; struct Z { Y y; explicit Z(Y y) : y(y) {} }; void f(Y const&); void test() { Y const y; Z z(y); z.y.o = 1; auto const w = z; f(w.y); } In copy constructor 'Y::Y(const Y&)', inlined from 'void test()' at <source>:19:10: <source>:7:8: warning: '*(int*)((char*)&y + offsetof(const Y, Y::o.std::optional<int>::<unnamed>.std::_Optional_base<int, true, true>::<unnamed>))' is used uninitialized [-Wuninitialized] 7 | struct Y { | ^ <source>: In function 'void test()': <source>:18:13: note: 'y' declared here 18 | Y const y; | ^ Most similar to #80635 and #86465, I think? Although this is -Wuninitialized, not -Wmaybe-uninitialized.
next reply other threads:[~2022-10-10 23:14 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-10-10 23:14 ed at catmur dot uk [this message] 2022-10-11 8:16 ` [Bug libstdc++/107206] " rguenth at gcc dot gnu.org 2022-10-11 10:10 ` redi at gcc dot gnu.org 2022-10-11 10:20 ` rguenth at gcc dot gnu.org 2022-10-11 10:22 ` [Bug tree-optimization/107206] " rguenth at gcc dot gnu.org 2022-10-14 16:53 ` jamborm at gcc dot gnu.org 2022-10-16 17:27 ` rguenther at suse dot de 2022-10-19 12:59 ` cvs-commit at gcc dot gnu.org 2022-11-16 12:13 ` cvs-commit at gcc dot gnu.org 2022-11-16 12:14 ` jamborm at gcc dot gnu.org 2022-11-28 22:22 ` pinskia 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-107206-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: linkBe 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).