llvm / llvm/llvm-project

Clang rejects valid compound requirement by substituting into return-type-requirement constraint too early

Open
#200,557 3 comments 0 reactions 0 assignees View on GitHub
clang:frontend concepts diverges-from:gcc
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

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

```c++
template
concept C1 = true;

template
concept C2 = requires { { 0 } -> C1; };

static_assert(C2);
```

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

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

Clang diagnostic:

```
error: static assertion failed
note: because 'int' does not satisfy 'C2'
note: because 'C1' would be invalid: type 'int' cannot be used prior to '::' because it has no members
```

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.