On Tue, Dec 01, 2020 at 04:05:22PM -0500, Jason Merrill wrote: > > I see cp_parser_late_parsing_default_args calls push_defarg_context, > > so perhaps it could check default_arg_context vector, except that > > convert_default_arg calls that too around calling break_out_target_exprs > > which in the patch is used to perform the late evaluation of the > > std::source_location::current() calls. So it might need to temporarily > > pop_defarg_context before break_out_target_exprs and push it again? > > How about forcing the constant evaluation in bot_manip?
That is probably a good idea anyway. > Or simpler might be to always defer immediate evaluation of > source_location::current() until genericize time. Will try this too. Though, I still wonder if it will be ok that we'll evaluate immediate functions other than std::source_location::current() during the late parsing of default arguments. Testcase could be something like: consteval bool foo (bool x) { if (x) throw 1; return false; } consteval bool bar (bool x = foo (true)) { return true; } struct S { consteval static bool baz (bool x = foo (true)) { return true; } }; constexpr bool a = bar (true); constexpr bool b = S::baz (true); We accept now bar, but reject baz. I think the foo (true) expressions are in both cases in immediate function context and therefore foo (true) calls are there not immediate invocations (sure, if one calls bar () or S::baz () then it will be invalid anyway). Jakub