This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/84978] [8 Regression] ICE in cxx_eval_constant_expression at gcc/cp/constexpr.c:4109
- From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 20 Mar 2018 12:02:33 +0000
- Subject: [Bug c++/84978] [8 Regression] ICE in cxx_eval_constant_expression at gcc/cp/constexpr.c:4109
- Auto-submitted: auto-generated
- References: <bug-84978-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84978
--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
So we can be more careful there and do:
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -4111,7 +4111,15 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx,
tree t,
/* We ask for an rvalue for the RESULT_DECL when indirecting
through an invisible reference, or in named return value
optimization. */
- return (*ctx->values->get (t));
+ if (tree *p = ctx->values->get (t))
+ return *p;
+ else
+ {
+ if (!ctx->quiet)
+ error ("%qE is not a constant expression", t);
+ *non_constant_p = true;
+ }
+ break;
case VAR_DECL:
if (DECL_HAS_VALUE_EXPR_P (t))