Date: Mon, 21 Jul 2025 16:56:10 +0000 From: bugzilla-noreply@freebsd.org To: toolchain@FreeBSD.org Subject: [Bug 288352] clang crash on devel/hpx while building tests Message-ID: <bug-288352-29464-VGiGPM7CJh@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-288352-29464@https.bugs.freebsd.org/bugzilla/> References: <bug-288352-29464@https.bugs.freebsd.org/bugzilla/>
next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D288352 --- Comment #3 from commit-hook@FreeBSD.org --- A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=3Dffc5ee0f57d56459df93f4107b9835ae7= 8a546b5 commit ffc5ee0f57d56459df93f4107b9835ae78a546b5 Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2025-07-21 16:55:23 +0000 Commit: Dimitry Andric <dim@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 substitut= ion (#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 functio= n'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 =3D 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 functio= n, resulting in a single-level template argument of the `f` itself. Howe= ver the default argument here could still reference the template paramete= rs 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 th= at. This patch also consolidates the tests for default arguments and remo= ves 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(-) --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-288352-29464-VGiGPM7CJh>