public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-7112] c++: Remove superflous assert [PR104403] Date: Tue, 8 Feb 2022 19:16:12 +0000 (GMT) [thread overview] Message-ID: <20220208191612.D3EC33858D1E@sourceware.org> (raw) https://gcc.gnu.org/g:1755141a9ea0dddabb52776cddc4c9325eed27c6 commit r12-7112-g1755141a9ea0dddabb52776cddc4c9325eed27c6 Author: Jakub Jelinek <jakub@redhat.com> Date: Tue Feb 8 20:15:42 2022 +0100 c++: Remove superflous assert [PR104403] I've added the assert because start_decl diagnoses such vars for C++20 and earlier: if (current_function_decl && VAR_P (decl) && DECL_DECLARED_CONSTEXPR_P (current_function_decl) && cxx_dialect < cxx23) but as can be seen, we cam trigger the assert in older standards e.g. during non-manifestly constant evaluation. Rather than refining the assert that DECL_EXPRs for such vars don't appear for C++20 and older if they are inside of functions declared constexpr this patch just removes the assert, the code rejects encountering those vars in constant expressions anyway. 2022-02-08 Jakub Jelinek <jakub@redhat.com> PR c++/104403 * constexpr.cc (cxx_eval_constant_expression): Don't assert DECL_EXPRs of TREE_STATIC vars may only appear in -std=c++23. * g++.dg/cpp0x/lambda/lambda-104403.C: New test. Diff: --- gcc/cp/constexpr.cc | 1 - gcc/testsuite/g++.dg/cpp0x/lambda/lambda-104403.C | 8 ++++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc index fd051172e00..9b8e0eced4b 100644 --- a/gcc/cp/constexpr.cc +++ b/gcc/cp/constexpr.cc @@ -6652,7 +6652,6 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, /* Allow __FUNCTION__ etc. */ && !DECL_ARTIFICIAL (r)) { - gcc_assert (cxx_dialect >= cxx23); if (!ctx->quiet) { if (CP_DECL_THREAD_LOCAL_P (r)) diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-104403.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-104403.C new file mode 100644 index 00000000000..f231d3ea2c9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-104403.C @@ -0,0 +1,8 @@ +// PR c++/104403 +// { dg-do compile { target c++11 } } + +int +main () +{ + []{ switch (0) { case 0: static int value; return &value; } }; +}
reply other threads:[~2022-02-08 19:16 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220208191612.D3EC33858D1E@sourceware.org \ --to=jakub@gcc.gnu.org \ --cc=gcc-cvs@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).