Skip to content

Commit 4c3514f

Browse files
authored
[clang] Fix a "!CodeSynthesisContexts.empty()" assertion failure when constructing aggregate deduction guides. (#89227)
We were missing to push an record to the instantiation stack in `DeclareAggregateDeductionGuideForTypeAlias`. This patch fixes that.
1 parent 73e7f2f commit 4c3514f

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

clang/lib/Sema/SemaTemplate.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3044,6 +3044,11 @@ FunctionTemplateDecl *DeclareAggregateDeductionGuideForTypeAlias(
30443044
return nullptr;
30453045

30463046
LocalInstantiationScope Scope(SemaRef);
3047+
Sema::InstantiatingTemplate BuildingDeductionGuides(
3048+
SemaRef, AliasTemplate->getLocation(), RHSDeductionGuide,
3049+
Sema::InstantiatingTemplate::BuildingDeductionGuidesTag{});
3050+
if (BuildingDeductionGuides.isInvalid())
3051+
return nullptr;
30473052

30483053
// Build a new template parameter list for the synthesized aggregate deduction
30493054
// guide by transforming the one from RHSDeductionGuide.

clang/test/SemaCXX/cxx20-ctad-type-alias.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,3 +279,13 @@ Bar t = Foo<K<Container>>();
279279

280280
Bar s = 1; // expected-error {{no viable constructor or deduction guide for deduction of template arguments of}}
281281
} // namespace test20
282+
283+
namespace test21 {
284+
template <typename T, unsigned N>
285+
struct Array { const T member[N]; };
286+
template <unsigned N>
287+
using String = Array<char, N>;
288+
289+
// Verify no crash on constructing the aggregate deduction guides.
290+
String s("hello");
291+
} // namespace test21

0 commit comments

Comments
 (0)