https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118775
--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Jason Merrill <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:e7523a40cb1787d52a638cf8a4f9eeb5212f770f commit r16-56-ge7523a40cb1787d52a638cf8a4f9eeb5212f770f Author: Jason Merrill <ja...@redhat.com> Date: Sun Apr 20 12:31:35 2025 -0400 c++: new size folding [PR118775] r15-7893 added a workaround for a case where we weren't registering (long)&a as invalid in a constant-expression, because build_new_1 had folded away the CONVERT_EXPR that we rely on to diagnose that problem. In general we want to defer most folding until cp_fold_function, so let's fold less here. We mainly want to expose constant size so we can treat it differently, and we already did any constexpr evaluation when initializing cst_outer_nelts, so fold_to_constant seems like the right choice. PR c++/118775 gcc/cp/ChangeLog: * constexpr.cc (cxx_eval_call_expression): Add assert. (fold_to_constant): Handle processing_template_decl. * init.cc (build_new_1): Use fold_to_constant. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/constexpr-new24.C: Adjust diagnostic.