This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/84582] [8 Regression] Rejected valid C++ code since r257961


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)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]