https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=288352
--- Comment #3 from commit-h...@freebsd.org --- A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=ffc5ee0f57d56459df93f4107b9835ae78a546b5 commit ffc5ee0f57d56459df93f4107b9835ae78a546b5 Author: Dimitry Andric <d...@freebsd.org> AuthorDate: 2025-07-21 16:55:23 +0000 Commit: Dimitry Andric <d...@freebsd.org> CommitDate: 2025-07-21 16:55:23 +0000 Merge commit 8ac140f39084 from llvm git (by Younan Zhang): [Clang][NFCI] Cleanup the fix for default function argument substitution (#104911) (This is one step towards tweaking `getTemplateInstantiationArgs()` as discussed in https://github.com/llvm/llvm-project/pull/102922) We don't always substitute into default arguments while transforming a function parameter. In that case, we would preserve the uninstantiated expression until after, e.g. building up a CXXDefaultArgExpr and instantiate the expression there. For member function instantiation, this algorithm used to cause a problem in that the default argument of an out-of-line member function specialization couldn't get properly instantiated. This is because, in `getTemplateInstantiationArgs()`, we would give up visiting a function's declaration context if the function is a specialization of a member template. For example, ```cpp template <class T> struct S { template <class U> void f(T = sizeof(T)); }; template <> template <class U> void S<int>::f(int) {} ``` The default argument `sizeof(U)` that lexically appears inside the declaration would be copied to the function declaration in the class template specialization `S<int>`, as well as to the function's out-of-line definition. We use template arguments collected from the out-of-line function definition when substituting into the default arguments. We would therefore give up the traversal after the function, resulting in a single-level template argument of the `f` itself. However the default argument here could still reference the template parameters of the primary template, hence the error. In fact, this is similar to constraint checking in some respects: we actually want the "whole" template arguments relative to the primary template, not those relative to the function definition. So this patch adds another flag to indicate `getTemplateInstantiationArgs()` for that. This patch also consolidates the tests for default arguments and removes some unnecessary tests. This fixes a crash or assertion failure while building tests for the devel/hpx port. PR: 288352 MFC after: 3 days .../llvm-project/clang/include/clang/Sema/Sema.h | 9 ++++++++- .../clang/lib/Sema/SemaTemplateInstantiate.cpp | 23 ++++++++-------------- .../clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 10 ++++++---- 3 files changed, 22 insertions(+), 20 deletions(-) -- You are receiving this mail because: You are the assignee for the bug.