Skip to content

[Clang] Fix a pack expansion bug in template argument deduction #141547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,7 @@ Bug Fixes to C++ Support
- Fix instantiation of default-initialized variable template specialization. (#GH140632) (#GH140622)
- Clang modules now allow a module and its user to differ on TrivialAutoVarInit*
- Fixed an access checking bug when initializing non-aggregates in default arguments (#GH62444), (#GH83608)
- Fixed a pack substitution bug in deducing class template partial specializations. (#GH53609)

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Sema/SemaTemplateDeduction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2946,6 +2946,7 @@ ConvertDeducedTemplateArgument(Sema &S, NamedDecl *Param,
LocalInstantiationScope Scope(S);
MultiLevelTemplateArgumentList Args(Template, CTAI.SugaredConverted,
/*Final=*/true);
Sema::ArgPackSubstIndexRAII OnlySubstNonPackExpansion(S, std::nullopt);

if (auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
Sema::InstantiatingTemplate Inst(S, Template->getLocation(), Template,
Expand Down
17 changes: 17 additions & 0 deletions clang/test/CXX/temp/temp.fct.spec/temp.deduct/p7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,20 @@ namespace reversed_operator_substitution_order {
float &s = no_adl::f<int>(true);
}
#endif

namespace GH53609 {

template <class, int>
struct a;

template <class, class...>
struct b;

template <class x, class... y, y... z>
struct b<x, a<y, z>...> {};

template <class... x> struct c: b<x>... {};

c<int> d;

}
Loading