llvm / llvm/llvm-project

Invalid template parameter packs dependent upon other template parameter packs in the same template parameter list are incorrectly accepted

Open
#214,757 1 comment 0 reactions 0 assignees View on GitHub
accepts-invalid clang:frontend cwg-issue diverges-from:gcc diverges-from:msvc
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

```cpp
templatestruct S{};
templatevoid foo(S...){}
int main(){
foo();
}
```
```cpp
templatevoid foo(){}
int main(){
foo();
}
```
These should both be invalid because of [[temp.param]/6](https://eel.is/c++draft/temp.param#6.sentence-5) "A template parameter pack that is a pack expansion shall not expand a template parameter pack declared in the same template-parameter-list.". GCC rejects the former but allows the latter, and MSVC rejects the latter but allows the former. See also: [CWG778](https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#778)

Contributor guide

Open the contributing guide

Research direction

Start by compiling both reduced C++ examples and compare Clang's behavior with the standard rule and the GCC/MSVC results described. Trace the compiler's validation of dependent template parameter packs and add regression coverage so both invalid forms are rejected consistently.

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
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.