https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104620
--- Comment #10 from Patrick Palka <ppalka at gcc dot gnu.org> --- (In reply to Jason Merrill from comment #8) > (In reply to Patrick Palka from comment #7) > > IIUC as long as NON_DEPENDENT_EXPR doesn't appear inside a non-dependent > > consteval call then we'll currently correctly accept/reject it ahead of > > time, e.g.: > > Right. The problem we're hitting is that within a template we're trying to > evaluate the immediate invocation inside build_over_call rather than when we > return to e.g. finish_call_expr and build up the call to actually go into > the template trees: if we fold_non_dependent_expr at that point instead, it > should be fine. The only problem with that is that there are a bunch of > places that need to be changed. That'd work for finish_call_expr and build_new_method call since they're given the original arguments, but other callers e.g. build_new_op never see the original arguments, so we wouldn't be able to do fold_non_dependent_expr from there IIUC. For build_new_op in particular, we'd have to instead fold_non_dependent_expr from _its_ callers, the build_x_* class of functions, I think..