-Wmissing-designated-field-initializers ignores members of the base classes
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
When a designated initializer is used, Clang ignores the members of the base classes and does not issue a warning. Even though there is no way to initialize the members of the base classes in this case, I think there should be a warning.
```cpp
struct BBase
{
int x; // non-default-inititialized
};
struct B : BBase
{
int a = 0;
int b;
};
int main()
{
(void)B{.b=1}; // no warning for `BBase::x` -> NOK
}
```
https://godbolt.org/z/x5Y1EjY5E (the comments were for g++)
Compared to GCC, it also seems to ignore members of base classes, but there is still a warning about the base classes themselves. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126319 (I'm putting this here on the assumption that there is a desire to align behavior).
Contributor guide
Research direction
Start with the C++ reproducer in the issue and the linked Compiler Explorer example to confirm the missing warning for BBase::x. Trace Clang's -Wmissing-designated-field-initializers handling for designated initialization and base classes, then add or update a regression test showing the expected diagnostic.
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