[Clang] Clang incorrectly calculates constraints involving private members and multiple nested classes of the same name
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Since Clang 22, Clang starts rejecting the following code snippet ([Godbolt link](https://godbolt.org/z/c89Tx5EeG)), which is perhaps incorrect.
Note that Clang behaves as expected if two nested classes are of different names.
```C++
struct A {
class Nested { // N.B. Both nested classes have the same name.
private:
static void test_function();
};
};
template
concept has_member_test_function = requires {
T::test_function();
};
static_assert(!has_member_test_function);
struct B {
struct Nested { // N.B. Both nested classes have the same name.
template
requires has_member_test_function
Nested(const T&);
};
};
template
concept quick_convertible_to = requires(From&& t, void (&fun)(To)) {
fun(static_cast(t));
};
static_assert(!quick_convertible_to);
```
Contributor guide
Research direction
Start by compiling the provided C++ reproducer from the Godbolt link with Clang 22 and a comparison version, confirming the rejection involving same-named nested classes and private members. Trace the constraint and conversion checks implicated by the reproducer; done means Clang accepts the code with both static assertions remaining valid.
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