Skip to content

Commit f8d6316

Browse files
authored
[Clang] Fix a pack expansion bug in template argument deduction (#141547)
I think the intent of df18ee9 was to substitute only those non-packs into a pack expansion type (e.g. `T` in `T::pack...`), so let's hold off pack expansions explicitly, in case there are calls coming from a substitution of pack expansion. Fixes #53609
1 parent 9e6fc8d commit f8d6316

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,7 @@ Bug Fixes to C++ Support
798798
- Fix instantiation of default-initialized variable template specialization. (#GH140632) (#GH140622)
799799
- Clang modules now allow a module and its user to differ on TrivialAutoVarInit*
800800
- Fixed an access checking bug when initializing non-aggregates in default arguments (#GH62444), (#GH83608)
801+
- Fixed a pack substitution bug in deducing class template partial specializations. (#GH53609)
801802

802803
Bug Fixes to AST Handling
803804
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/Sema/SemaTemplateDeduction.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2946,6 +2946,7 @@ ConvertDeducedTemplateArgument(Sema &S, NamedDecl *Param,
29462946
LocalInstantiationScope Scope(S);
29472947
MultiLevelTemplateArgumentList Args(Template, CTAI.SugaredConverted,
29482948
/*Final=*/true);
2949+
Sema::ArgPackSubstIndexRAII OnlySubstNonPackExpansion(S, std::nullopt);
29492950

29502951
if (auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
29512952
Sema::InstantiatingTemplate Inst(S, Template->getLocation(), Template,

clang/test/CXX/temp/temp.fct.spec/temp.deduct/p7.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,20 @@ namespace reversed_operator_substitution_order {
5454
float &s = no_adl::f<int>(true);
5555
}
5656
#endif
57+
58+
namespace GH53609 {
59+
60+
template <class, int>
61+
struct a;
62+
63+
template <class, class...>
64+
struct b;
65+
66+
template <class x, class... y, y... z>
67+
struct b<x, a<y, z>...> {};
68+
69+
template <class... x> struct c: b<x>... {};
70+
71+
c<int> d;
72+
73+
}

0 commit comments

Comments
 (0)