llvm / llvm/llvm-project

Clang accepts a default template argument on a variable-template partial specialization

Open
#200,784 4 comments 0 reactions 0 assignees View on GitHub
accepts-invalid clang:frontend diverges-from:edg diverges-from:gcc
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Clang 22 accepts the following C++20 program, while Clang GCC 15.2.0 rejects it:

```c++
template
int var_template = 0;

template
int var_template;

int *p = &var_template;
```

Clang: clang++-22 22.0.0
-std=c++20: accepts
-std=c++20 -pedantic-errors: accepts

GCC: gcc15 15.2.0
-std=c++20: rejects
-std=c++20 -pedantic-errors: rejects

GCC diagnostic:
error: default template arguments may not be used in partial specializations

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.