The logic in type_unification_real for handling template parms that depend on earlier template parms is a bit complicated. It already recognizes when the type of the parm depends on something not available yet, and it dealt with the case where substituting partial args left some template parm uses behind, but it didn't handle the case where substituting partial args just failed. Tested x86_64-pc-linux-gnu, applying to trunk.