[clang] "incomplete type 'const A' is not a literal type" for a static constexpr data member
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Not sure if this is a bug or not, bug gcc compiles this code just fine:
```c++
template
struct Mixin {
static constexpr Base base{};
};
struct A {
Mixin m;
};
```
while clang argues:
```
:3:25: error: constexpr variable cannot have non-literal type 'const A'
3 | static constexpr Base base{};
| ^
:7:14: note: in instantiation of template class 'Mixin' requested here
7 | Mixin m;
| ^
:3:25: note: incomplete type 'const A' is not a literal type
3 | static constexpr Base base{};
| ^
:6:8: note: definition of 'A' is not complete until the closing '}'
6 | struct A {
| ^
```
https://godbolt.org/z/YbvW4Gq3n
Contributor guide
Research direction
Begin with the minimal C++ snippet and Godbolt link, comparing Clang and GCC behavior. Trace Clang's handling of the static constexpr member while A is incomplete and determine whether the diagnostic matches the language rules. Done means the issue is resolved with behavior or a diagnostic justified by the standard.
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
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100