public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/107206] Bogus -Wuninitialized in std::optional Date: Tue, 11 Oct 2022 08:16:05 +0000 [thread overview] Message-ID: <bug-107206-4-pwfrSFuV15@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-107206-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107206 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Component|c++ |libstdc++ Status|UNCONFIRMED |NEW Last reconfirmed| |2022-10-11 Ever confirmed|0 |1 --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- Confirmed. We diagnose <bb 2> [local count: 1073741824]: MEM[(struct optional *)&y + 4B] ={v} {CLOBBER}; MEM[(union _Storage *)&y + 4B] ={v} {CLOBBER}; MEM[(struct _Optional_payload_base *)&y + 4B]._M_engaged = 0; D.11546.o = y.o; SR.27_14 = MEM <int> [(struct optional *)&y + 4B]; <--------- this MEM <int> [(struct optional *)&D.11546 + 4B] = SR.27_14; MEM <unsigned char> [(struct optional *)&D.11546 + 8B] = 0; MEM[(struct Y *)&z].o = MEM[(const struct Y &)&D.11546].o; D.11546 ={v} {CLOBBER(eol)}; MEM[(struct Y *)&w] ={v} {CLOBBER}; MEM[(struct X *)&w] ={v} {CLOBBER}; MEM[(struct X *)&w].i = 0; MEM <int> [(struct optional *)&z + 4B] = 1; MEM <unsigned char> [(struct optional *)&z + 8B] = 1; MEM[(struct Y *)&w].o = MEM[(const struct Y &)&z].o; f (&w.y); y ={v} {CLOBBER(eol)}; z ={v} {CLOBBER(eol)}; w ={v} {CLOBBER(eol)}; return; Here the aggregate copy D.11546.o = y.o; is effectively scalarized and that accesses the data member of the not engaged std::optional<>. IMHO that's a standard library issue? The copy is due to the by value passing and we get in .original <<cleanup_point <<< Unknown tree: expr_stmt Z::Z (&z, &TARGET_EXPR <D.11546, <<< Unknown tree: aggr_init_expr 5 __ct_comp D.11546 (struct Y *) <<< Unknown tree: void_cst >>> (const struct Y &) &y >>>>) >>>>>; which eventually leads to Y::Y (&D.11546, &y); Z::Z (&z, &D.11546); which contains void Y::Y (struct Y * const this, const struct Y & D.11498) { *this = {CLOBBER}; { _1 = &this->x; _2 = &D.11498->x; X::X (_1, _2); this->o = D.11498->o; } so the std::optional<> is simply aggregate copied, accessing any not engaged member. GCC is correct in diagnosing this uninitialized access.
next prev parent reply other threads:[~2022-10-11 8:16 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-10-10 23:14 [Bug c++/107206] New: " ed at catmur dot uk 2022-10-11 8:16 ` rguenth at gcc dot gnu.org [this message] 2022-10-11 10:10 ` [Bug libstdc++/107206] " 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-pwfrSFuV15@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).