ychen added inline comments.
================ Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:5511-5539 + template <typename T1, typename T2, + std::enable_if_t<std::is_same<T1, T2>::value, bool> = true> + bool operator()(T1 *PS1, T2 *PS2) { + return hasEqualTemplateArgumentList( + PS1->getTemplateArgsAsWritten()->arguments(), + PS2->getTemplateArgsAsWritten()->arguments()); + } ---------------- mizvekov wrote: > I think you are not supposed to use the `TemplateArgsAsWritten` here. > > The injected arguments are 'Converted' arguments, and the transformation > above, by unpacking the arguments, is reversing just a tiny part of the > conversion process. > > It's not very meaningful to canonicalize the arguments as written to perform > a semantic comparison, as that works well just for some kinds of template > arguments, like types and templates, but not for other kinds in which the > conversion process is not trivial. > > For example, I think this may fail to compare the same integers written in > different ways, like `2` vs `1 + 1`. Indeed. It can happen only when comparing one partial specialization with another. I think the standard does not require an implementation to deal with this but we could use the best effort without much overhead. For `2` vs `1+1` or similar template arguments that are not dependent, we could assume the equivalence because they wouldn't be in the partial ordering stage if they're not equivalent. For more complicated cases like `J+2` vs `J+1+1` where J is NTTP, let's stop trying (match GCC) because the overhead is a little bit high. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D128750/new/ https://reviews.llvm.org/D128750 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits