llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Krisitan Erik Olsen (Kristianerik) <details> <summary>Changes</summary> When a type alias template's aggregate deduction guide could not be resolved, `DeclareAggregateDeductionGuideFromInitList` would fall through to the `ClassTemplateDecl` code path, which unconditionally casts the template's underlying decl to `CXXRecordDecl`. For alias templates this is a `TypeAliasDecl`, causing an assertion failure (or SIGSEGV in non-assertions builds). The sibling function `DeclareImplicitDeductionGuides` handles this correctly — it always returns after the alias template branch and uses `dyn_cast_or_null` instead of `cast` for the non-alias path. This patch adds the missing `return nullptr` to match that pattern. Likely related to #<!-- -->176389 (same crash site, could not reproduce locally). Fixes #<!-- -->206994 --- Full diff: https://github.com/llvm/llvm-project/pull/207478.diff 2 Files Affected: - (modified) clang/lib/Sema/SemaTemplateDeductionGuide.cpp (+1) - (added) clang/test/SemaTemplate/ctad-alias-aggregate-crash.cpp (+17) ``````````diff diff --git a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp index fa740d5581e5f..ab8e6a3555d90 100644 --- a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp +++ b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp @@ -1606,6 +1606,7 @@ CXXDeductionGuideDecl *Sema::DeclareAggregateDeductionGuideFromInitList( AggregateDeductionCandidates[Hash] = GD; return GD; } + return nullptr; } if (CXXRecordDecl *DefRecord = diff --git a/clang/test/SemaTemplate/ctad-alias-aggregate-crash.cpp b/clang/test/SemaTemplate/ctad-alias-aggregate-crash.cpp new file mode 100644 index 0000000000000..e3cf256af86cb --- /dev/null +++ b/clang/test/SemaTemplate/ctad-alias-aggregate-crash.cpp @@ -0,0 +1,17 @@ +// RUN: not %clang_cc1 -std=c++23 -fsyntax-only %s +// Reduced from a fuzzer-generated crash report. +// Ensure we don't crash when aggregate deduction guide resolution +// fails for a type alias template during CTAD. +__detail __detail:); +template _Tptypename convertible_to_Tpcommon_reference_t_Tp_Up } +requires0template +namespace ranges __iter_traits >; +template __iter_diff_tremove_cvref_t_Tp rangesiter_swap0 +namespace detail { +template < typename > struct difference_type_ +} +template < typename T > using difference_type = difference_type_< T >; +namespace detail { +template < typename T > +struct difference_type_ : T +} difference_type alloc_limit = 4 `````````` </details> https://github.com/llvm/llvm-project/pull/207478 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
