public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/96994] Missing code from consteval constructor initializing const variable Date: Mon, 14 Sep 2020 13:11:55 +0000 [thread overview] Message-ID: <bug-96994-4-mHUnEWvOsa@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-96994-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96994 --- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> --- So, what I see is that expand_default_init calls build_special_member_call for the default ctor, but because the default ctor is an immediate method, it returns a TARGET_EXPR with CONSTRUCTOR as the initializer, rather than a call. expand_default_init doesn't return anything, just appends the rval as statement, but that doesn't really do anything. So, one way to fix this would be in expand_default_init check for rval being a TARGET with TREE_CONSTANT as the initializer and if it is that, build an INIT_EXPR like it e.g. does that for constexpr ctors. --- gcc/cp/init.c.jj 2020-09-10 11:24:05.019805303 +0200 +++ gcc/cp/init.c 2020-09-14 15:06:59.467341241 +0200 @@ -1999,6 +1999,9 @@ expand_default_init (tree binfo, tree tr rval = build2 (INIT_EXPR, type, exp, e); } } + else if (TREE_CODE (rval) == TARGET_EXPR + && TREE_CONSTANT (TARGET_EXPR_INITIAL (rval))) + rval = build2 (INIT_EXPR, type, exp, rval); /* FIXME put back convert_to_void? */ if (TREE_SIDE_EFFECTS (rval)) fixes the testcase
next prev parent reply other threads:[~2020-09-14 13:11 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-09-09 11:27 [Bug c++/96994] New: " sbergman at redhat dot com 2020-09-09 22:06 ` [Bug c++/96994] " mpolacek at gcc dot gnu.org 2020-09-10 17:52 ` jakub at gcc dot gnu.org 2020-09-10 17:55 ` jakub at gcc dot gnu.org 2020-09-10 18:00 ` mpolacek at gcc dot gnu.org 2020-09-10 18:10 ` jakub at gcc dot gnu.org 2020-09-10 18:11 ` jakub at gcc dot gnu.org 2020-09-14 13:11 ` jakub at gcc dot gnu.org [this message] 2020-09-21 20:08 ` mpolacek at gcc dot gnu.org 2020-10-01 9:19 ` cvs-commit at gcc dot gnu.org 2020-10-05 8:25 ` cvs-commit at gcc dot gnu.org 2021-04-20 15:12 ` jakub 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-96994-4-mHUnEWvOsa@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).