public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "hi+gccbugs at yamlcoder dot me" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/105749] New: Bogus maybe-unitialized when using std::optional, regex and sstream Date: Fri, 27 May 2022 10:13:05 +0000 [thread overview] Message-ID: <bug-105749-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105749 Bug ID: 105749 Summary: Bogus maybe-unitialized when using std::optional, regex and sstream Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: hi+gccbugs at yamlcoder dot me Target Milestone: --- Created attachment 53044 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53044&action=edit t.ii reproducer Compiling following with -Wall -Werror -Os produces bogus maybe-unitialized warning /tmp/t.cpp: In function ‘void t(const string&)’: /tmp/t.cpp:12:51: error: ‘*(int*)((char*)&port + offsetof(std::optional<int>,std::optional<int>::<unnamed>.std::_Optional_base<int, true, true>::<unnamed>))’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 12 | reqb << "Host: " << port.value_or(443) << "\r\n"; Attaching .ii (tar.gz due to attachment limit) file from 11.2.0, but it is also reproducible on trunk in godbolt: https://godbolt.org/z/ha3vn61n9 Interesting that commenting unrelated parts or changing them slightly makes warning go away. #include <regex> #include <optional> #include <sstream> void t(const std::string& i) { const std::regex re("^$"); //removing this works std::optional<int> port(i.length() > 0 ? std::make_optional(std::strtol("99", nullptr, 10)) : std::nullopt); std::ostringstream reqb; reqb << "GET /" << i << " HTTP/1.1" << "\r\n"; //removing this works reqb << "Host: " << port.value_or(443) << "\r\n"; }
next reply other threads:[~2022-05-27 10:13 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-05-27 10:13 hi+gccbugs at yamlcoder dot me [this message] 2022-06-22 20:20 ` [Bug tree-optimization/105749] " pinskia at gcc dot gnu.org 2022-06-22 20:23 ` pinskia at gcc dot gnu.org 2022-06-22 20:24 ` pinskia at gcc dot gnu.org 2022-09-22 13:25 ` rguenth 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-105749-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).