This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/84582] [8 Regression] Rejected valid C++ code since r257961
- 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, 27 Feb 2018 11:17:03 +0000
- Subject: [Bug c++/84582] [8 Regression] Rejected valid C++ code since r257961
- Auto-submitted: auto-generated
- References: <bug-84582-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84582
--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
It looks like we shouldn't skip the evaluation when ALLOW_NON_CONSTANT is
false, similarly to the CONSTANT_CLASS_P case:
@@ -5137,10 +5147,10 @@ maybe_constant_init_1 (tree t, tree decl, bool
allow_non_constant)
t = TREE_OPERAND (t, 1);
if (TREE_CODE (t) == TARGET_EXPR)
t = TARGET_EXPR_INITIAL (t);
- if (!is_nondependent_static_init_expression (t))
+ if (allow_non_constant
+ && (!is_nondependent_static_init_expression (t)
+ || CONSTANT_CLASS_P (t)))
/* Don't try to evaluate it. */;
- else if (CONSTANT_CLASS_P (t) && allow_non_constant)
- /* No evaluation needed. */;
else
t = cxx_eval_outermost_constant_expr (t, allow_non_constant, false, decl);
if (TREE_CODE (t) == TARGET_EXPR)