https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96097
--- Comment #8 from Marek Polacek <mpolacek at gcc dot gnu.org> --- Here, make_typename_type is called when tsubsting, i.e. p_t_d is 0, and it calls dependent_scope_p with a dependent type. We might need ++ptd/--ptd around the call to make_typename_type.