https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97681

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Guess that particular spot could be changed with:
--- gcc/cp/typeck2.c    2020-09-12 13:36:42.500499341 +0200
+++ gcc/cp/typeck2.c    2020-11-03 10:44:10.257021110 +0100
@@ -935,9 +935,11 @@ store_init_value (tree decl, tree init,
     }
   /* Don't fold initializers of automatic variables in constexpr functions,
      that might fold away something that needs to be diagnosed at constexpr
-     evaluation time.  */
+     evaluation time.  Don't fold initializers of automatic variables
+     with -O0 either.  */
   if (!current_function_decl
-      || !DECL_DECLARED_CONSTEXPR_P (current_function_decl)
+      || (!DECL_DECLARED_CONSTEXPR_P (current_function_decl)
+         && optimize)
       || TREE_STATIC (decl))
     value = cp_fully_fold_init (value);

but we have dozens if not hundreds of other places.  And, just disabling
constant evaluation at -O0 except in manifestly constant contexts can't really
work, e.g. many of the warnings heavily relies on the foldings being possible.

Reply via email to