Skip to content

Commit

Permalink
[Clang] fix crash due to incorrect argument position in merging deduc…
Browse files Browse the repository at this point in the history
…ed template arguments (#118041)

Fixes #113659
  • Loading branch information
a-tarasyuk authored Nov 29, 2024
1 parent 77c2b00 commit be75a14
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,7 @@ Bug Fixes to C++ Support
missing placeholder return type. (#GH78694)
- Fixed a bug where bounds of partially expanded pack indexing expressions were checked too early. (#GH116105)
- Fixed an assertion failure caused by using ``consteval`` in condition in consumed analyses. (#GH117385)
- Fix a crash caused by incorrect argument position in merging deduced template arguments. (#GH113659)

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
3 changes: 2 additions & 1 deletion clang/lib/Sema/SemaTemplateDeduction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,14 +376,15 @@ checkDeducedTemplateArguments(ASTContext &Context,
for (TemplateArgument::pack_iterator
XA = X.pack_begin(),
XAEnd = X.pack_end(), YA = Y.pack_begin(), YAEnd = Y.pack_end();
XA != XAEnd; ++XA, ++YA) {
XA != XAEnd; ++XA) {
if (YA != YAEnd) {
TemplateArgument Merged = checkDeducedTemplateArguments(
Context, DeducedTemplateArgument(*XA, X.wasDeducedFromArrayBound()),
DeducedTemplateArgument(*YA, Y.wasDeducedFromArrayBound()));
if (Merged.isNull() && !(XA->isNull() && YA->isNull()))
return DeducedTemplateArgument();
NewPack.push_back(Merged);
++YA;
} else {
NewPack.push_back(*XA);
}
Expand Down
12 changes: 12 additions & 0 deletions clang/test/SemaTemplate/template-args-deduction-aggregates.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++20

// expected-no-diagnostics

namespace GH113659 {
template <class... Args> struct S {};
struct T {};
struct U {};

template <class... Args> struct B : S<Args...>, Args... {};
B b{S<T, U>{}};
}

0 comments on commit be75a14

Please sign in to comment.