public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/108243] [10/11/12/13 Regression] Missed optimization for static const std::string_view(const char*) Date: Thu, 02 Mar 2023 19:05:07 +0000 [thread overview] Message-ID: <bug-108243-4-yFyFqn1S5t@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-108243-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108243 --- Comment #12 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>: https://gcc.gnu.org/g:cbaa1d9c218d9c0b5e34e510a462ff4e299a0f3f commit r13-6421-gcbaa1d9c218d9c0b5e34e510a462ff4e299a0f3f Author: Patrick Palka <ppalka@redhat.com> Date: Thu Mar 2 14:03:21 2023 -0500 c++: constant non-copy-init is manifestly constant [PR108243] According to [basic.start.static]/2 and [expr.const]/2, a variable with static storage duration initialized with a constant initializer has constant initialization, and such an initializer is manifestly constant-evaluated. For copy initialization, we're already getting this right because in that case check_initializer would consistently call store_init_value, which for TREE_STATIC variables calls fold_non_dependent_init with m_c_e=true. But for direct (or default) initialization, check_initializer doesn't always call store_init_value. We instead however always call maybe_constant_init from expand_default_init[1], albeit with m_c_e=false which means we don't get the "manifestly constant-evaluated" part right for non-copy-init. This patch fixes this by setting m_c_e=true in maybe_constant_init for static storage duration variables, mainly for benefit of the call to maybe_constant_init from expand_default_init. [1]: this maybe_constant_init call isn't reached in the copy-init case because there init is a CONSTRUCTOR rather than a TREE_LIST, and so we exit early from expand_default_init, returning an INIT_EXPR. This INIT_EXPR is ultimately what causes us to consistently hit the store_init_value code path from check_initializer in the copy-init case. PR c++/108243 gcc/cp/ChangeLog: * constexpr.cc (maybe_constant_init_1): Override manifestly_const_eval to true if is_static. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/is-constant-evaluated14.C: New test.
next prev parent reply other threads:[~2023-03-02 19:05 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-12-28 16:31 [Bug c++/108243] New: " erosenberger at kinetica dot com 2023-01-04 11:42 ` [Bug c++/108243] " redi at gcc dot gnu.org 2023-01-04 13:05 ` redi at gcc dot gnu.org 2023-01-04 13:15 ` redi at gcc dot gnu.org 2023-01-04 13:20 ` [Bug c++/108243] [10/11/12/13 Regression] " redi at gcc dot gnu.org 2023-01-04 13:21 ` redi at gcc dot gnu.org 2023-01-04 16:47 ` ppalka at gcc dot gnu.org 2023-01-04 17:22 ` jakub at gcc dot gnu.org 2023-01-09 14:05 ` rguenth at gcc dot gnu.org 2023-01-27 19:13 ` ppalka at gcc dot gnu.org 2023-02-17 20:21 ` cvs-commit at gcc dot gnu.org 2023-02-20 5:23 ` de34 at live dot cn 2023-02-20 18:33 ` ppalka at gcc dot gnu.org 2023-02-21 13:38 ` rguenth at gcc dot gnu.org 2023-02-21 14:09 ` ppalka at gcc dot gnu.org 2023-03-02 19:05 ` cvs-commit at gcc dot gnu.org [this message] 2023-03-02 19:05 ` cvs-commit at gcc dot gnu.org 2023-03-02 19:51 ` [Bug c++/108243] [10/11/12 " ppalka at gcc dot gnu.org 2023-07-07 10:44 ` [Bug c++/108243] [11/12 " rguenth at gcc dot gnu.org 2023-12-13 16:48 ` cvs-commit 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-108243-4-yFyFqn1S5t@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).