Skip to content

Commit be75a14

Browse files
authored
[Clang] fix crash due to incorrect argument position in merging deduced template arguments (llvm#118041)
Fixes llvm#113659
1 parent 77c2b00 commit be75a14

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,7 @@ Bug Fixes to C++ Support
762762
missing placeholder return type. (#GH78694)
763763
- Fixed a bug where bounds of partially expanded pack indexing expressions were checked too early. (#GH116105)
764764
- Fixed an assertion failure caused by using ``consteval`` in condition in consumed analyses. (#GH117385)
765+
- Fix a crash caused by incorrect argument position in merging deduced template arguments. (#GH113659)
765766

766767
Bug Fixes to AST Handling
767768
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/Sema/SemaTemplateDeduction.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,14 +376,15 @@ checkDeducedTemplateArguments(ASTContext &Context,
376376
for (TemplateArgument::pack_iterator
377377
XA = X.pack_begin(),
378378
XAEnd = X.pack_end(), YA = Y.pack_begin(), YAEnd = Y.pack_end();
379-
XA != XAEnd; ++XA, ++YA) {
379+
XA != XAEnd; ++XA) {
380380
if (YA != YAEnd) {
381381
TemplateArgument Merged = checkDeducedTemplateArguments(
382382
Context, DeducedTemplateArgument(*XA, X.wasDeducedFromArrayBound()),
383383
DeducedTemplateArgument(*YA, Y.wasDeducedFromArrayBound()));
384384
if (Merged.isNull() && !(XA->isNull() && YA->isNull()))
385385
return DeducedTemplateArgument();
386386
NewPack.push_back(Merged);
387+
++YA;
387388
} else {
388389
NewPack.push_back(*XA);
389390
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++20
2+
3+
// expected-no-diagnostics
4+
5+
namespace GH113659 {
6+
template <class... Args> struct S {};
7+
struct T {};
8+
struct U {};
9+
10+
template <class... Args> struct B : S<Args...>, Args... {};
11+
B b{S<T, U>{}};
12+
}

0 commit comments

Comments
 (0)