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++/104507] [10/11 Regression] internal compiler error: unexpected expression ‘(int)(__ret)’ of kind cast_expr Date: Tue, 12 Apr 2022 23:44:30 +0000 [thread overview] Message-ID: <bug-104507-4-WTguT1dCwR@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-104507-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104507 --- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-11 branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>: https://gcc.gnu.org/g:c8aaa9cca96207b5674048972c82a338ef81ce7e commit r11-9843-gc8aaa9cca96207b5674048972c82a338ef81ce7e Author: Patrick Palka <ppalka@redhat.com> Date: Wed Feb 16 12:41:35 2022 -0500 c++: treat NON_DEPENDENT_EXPR as not potentially constant [PR104507] Here we're crashing from potential_constant_expression because it tries to perform trial evaluation of the first operand '(bool)__r' of the conjunction (which is overall wrapped in a NON_DEPENDENT_EXPR), but cxx_eval_constant_expression ICEs on unsupported trees (of which CAST_EXPR is one). The sequence of events is: 1. build_non_dependent_expr for the array subscript yields NON_DEPENDENT_EXPR<<<(bool)__r && __s>>> ? 1 : 2 2. cp_build_array_ref calls fold_non_dependent_expr on this subscript (after this point, processing_template_decl is cleared) 3. during which, the COND_EXPR case of tsubst_copy_and_build calls fold_non_dependent_expr on the first operand 4. during which, we crash from p_c_e_1 because it attempts trial evaluation of the CAST_EXPR '(bool)__r'. Note that even if this crash didn't happen, fold_non_dependent_expr from cp_build_array_ref would still ultimately be one big no-op here since neither constexpr evaluation nor tsubst handle NON_DEPENDENT_EXPR. In light of this and of the observation that we should never see NON_DEPENDENT_EXPR in a context where a constant expression is needed (it's used primarily in the build_x_* family of functions), it seems futile for p_c_e_1 to ever return true for NON_DEPENDENT_EXPR. And the otherwise inconsistent handling of NON_DEPENDENT_EXPR between p_c_e_1, cxx_evaluate_constexpr_expression and tsubst apparently leads to weird bugs such as this one. PR c++/104507 gcc/cp/ChangeLog: * constexpr.c (potential_constant_expression_1) <case NON_DEPENDENT_EXPR>: Return false instead of recursing. Assert tf_error isn't set. gcc/testsuite/ChangeLog: * g++.dg/template/non-dependent21.C: New test. (cherry picked from commit c19f317a78c0e4c1b51d0e5a8e4c0a3b985b7a8e)
next prev parent reply other threads:[~2022-04-12 23:44 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-02-11 21:45 [Bug c++/104507] New: " junk at sigpwr dot com 2022-02-11 21:51 ` [Bug c++/104507] " pinskia at gcc dot gnu.org 2022-02-11 21:53 ` [Bug c++/104507] [10/11 Regression] " pinskia at gcc dot gnu.org 2022-02-13 8:47 ` junk at sigpwr dot com 2022-02-13 23:03 ` pinskia at gcc dot gnu.org 2022-02-14 0:57 ` junk at sigpwr dot com 2022-02-14 8:32 ` rguenth at gcc dot gnu.org 2022-02-14 11:18 ` jakub at gcc dot gnu.org 2022-02-14 16:57 ` [Bug c++/104507] [10/11/12 " ppalka at gcc dot gnu.org 2022-02-15 16:17 ` ppalka at gcc dot gnu.org 2022-02-16 17:42 ` cvs-commit at gcc dot gnu.org 2022-02-16 17:43 ` [Bug c++/104507] [10/11 " ppalka at gcc dot gnu.org 2022-04-12 23:44 ` cvs-commit at gcc dot gnu.org [this message] 2022-05-04 0:22 ` [Bug c++/104507] [10 " ppalka 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-104507-4-WTguT1dCwR@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).