public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "geoff3jones at googlemail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/86465] [9/10/11/12 Regression] C++17 <optional> triggers: ‘<anonymous>’ may be used uninitialized in this function Date: Wed, 12 Jan 2022 10:16:59 +0000 [thread overview] Message-ID: <bug-86465-4-HNT2K1x8bh@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-86465-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86465 --- Comment #16 from Geoff <geoff3jones at googlemail dot com> --- This appears to still be an issue in gcc 11.2 minimal reproduced example using std::optional https://godbolt.org/z/ebbMe3Wva. -std=c++17 -O3 -fsanitize=address -Wall -Werror -Wno-unused std::optional<bool> empty_optional_or_true(int x){ if(x > 0){ return std::make_optional(true); } return {}; // ^ error here } int main(){ empty_optional_or_true(0) } ------------ In function 'std::optional<bool> empty_optional_or_true(int)', inlined from 'std::optional<bool> empty_optional_or_true(int)' at <source>:28:21: <source>:7:13: error: '*(unsigned char*)((char*)&<unnamed> + offsetof(std::optional<bool>,std::optional<bool>::<unnamed>.std::_Optional_base<bool, true, true>::<unnamed>))' may be used uninitialized [-Werror=maybe-uninitialized] 7 | return {}; | ^ <source>: In function 'std::optional<bool> empty_optional_or_true(int)': <source>:7:13: note: '<anonymous>' declared here 7 | return {}; // <- second here | In the linked example it can be see that making the global function static or wrapping it in an anonymous namespace will cause the error to disappear.
next prev parent reply other threads:[~2022-01-12 10:16 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-86465-4@http.gcc.gnu.org/bugzilla/> 2020-10-27 14:45 ` [Bug c++/86465] [8/9/10/11 " redi at gcc dot gnu.org 2020-11-16 21:09 ` redi at gcc dot gnu.org 2021-04-08 16:08 ` [Bug tree-optimization/86465] " jason at gcc dot gnu.org 2021-05-14 9:50 ` [Bug tree-optimization/86465] [9/10/11/12 " jakub at gcc dot gnu.org 2021-06-01 8:11 ` rguenth at gcc dot gnu.org 2022-01-12 9:59 ` geoff3jones at googlemail dot com 2022-01-12 10:16 ` geoff3jones at googlemail dot com [this message] 2022-01-12 10:22 ` marc@nieper-wisskirchen.de 2022-01-12 12:12 ` marc@nieper-wisskirchen.de 2022-05-27 9:39 ` [Bug tree-optimization/86465] [10/11/12/13 " rguenth at gcc dot gnu.org 2022-06-28 10:35 ` jakub at gcc dot gnu.org 2022-09-22 13:11 ` 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-86465-4-HNT2K1x8bh@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).