https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89767
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> --- GCC 7.x and earlier used to do: /* The local structure or class can't use parameters of the containing function anyway. */ if (DECL_CONTEXT (oldlocal) != current_function_decl) { cp_binding_level *scope = current_binding_level; tree context = DECL_CONTEXT (oldlocal); for (; scope; scope = scope->level_chain) { if (scope->kind == sk_function_parms && scope->this_entity == context) break; if (scope->kind == sk_class && !LAMBDA_TYPE_P (scope->this_entity)) { nowarn = true; break; } } } but r248123 after moving it to a different function changed it to: /* The local structure or class can't use parameters of the containing function anyway. */ if (DECL_CONTEXT (old) != current_function_decl) { for (cp_binding_level *scope = current_binding_level; scope != old_scope; scope = scope->level_chain) if (scope->kind == sk_class && !LAMBDA_TYPE_P (scope->this_entity)) return; } If old comes from a different function, such as in this case where there are two nested instantiate_decl calls, one (the inner one) for av function above, another one for aw, and I believe especially because the two functions aren't lexically nested, it is just not possible to reach the old_scope (from the aw function) from current_binding_level (in av function).