llvm / llvm/llvm-project

[clang] Wrong class specialization is selected when alias template is used for template template parameter

Open
#167,320 6 comments 0 reactions 0 assignees View on GitHub
clang:frontend diverges-from:edg diverges-from:gcc
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

The second static assert in the following trivial example code fails due to incorrect class specialization being selected:
```C++
template class, class>
struct match_class_specialization
{
enum { matches = 0 };
};

template class Type, typename... Ts>
struct match_class_specialization>
{
enum { matches = 1 };
};

template struct my_type {};

static_assert(match_class_specialization>{}.matches);

template using my_type_alias = my_type;

static_assert(match_class_specialization>{}.matches);

int main() {}
```
This compiles fine in GCC.

Contributor guide

Open the contributing guide

Research direction

Start with the minimal C++ reproducer in the issue and compile it with Clang, then compare the result with GCC. Trace the template-template-parameter and alias-template specialization selection involved in the failing second static assertion; done means the alias-template case selects the matching specialization and the assertion passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.