ill-formed use of __builtin_structured_binding_size in requires clause causing hard error
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
i feel that the following should compile:
```c++
struct S
{
int a=0,b=0,c=0;
};
struct T : private S
{};
int main()
{
static_assert(!requires { __builtin_structured_binding_size(T); });
}
```
with clang trunk, i get:
```
:12:63: error: cannot bind members of inaccessible base class 'S' of 'T'
12 | static_assert(!requires { __builtin_structured_binding_size(T); });
| ^
:7:12: note: declared private here
7 | struct T : private S
| ^~~~~~~~~
:12:63: error: cannot bind private member 'a' of 'S'
12 | static_assert(!requires { __builtin_structured_binding_size(T); });
| ^
:7:12: note: constrained by private inheritance here
7 | struct T : private S
| ^~~~~~~~~
:4:7: note: member is declared here
4 | int a=0,b=0,c=0;
| ^
:12:63: error: cannot bind private member 'b' of 'S'
12 | static_assert(!requires { __builtin_structured_binding_size(T); });
| ^
:7:12: note: constrained by private inheritance here
7 | struct T : private S
| ^~~~~~~~~
:4:11: note: member is declared here
4 | int a=0,b=0,c=0;
| ^
:12:63: error: cannot bind private member 'c' of 'S'
12 | static_assert(!requires { __builtin_structured_binding_size(T); });
| ^
:7:12: note: constrained by private inheritance here
7 | struct T : private S
| ^~~~~~~~~
:4:15: note: member is declared here
4 | int a=0,b=0,c=0;
| ^
:12:17: error: static assertion failed due to requirement '!requires { __builtin_structured_binding_size(T); }'
12 | static_assert(!requires { __builtin_structured_binding_size(T); });
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 errors generated.
Compiler returned: 1
```
https://godbolt.org/z/jf6b71doc
Contributor guide
Research direction
Start by reducing the provided C++ reproducer and inspect Clang's handling of __builtin_structured_binding_size inside a requires expression, especially with private inheritance and inaccessible members. No source file or test path is named in the report; done means the reproducer no longer produces hard diagnostics and the invalid requirement is handled as false.
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