-
Couldn't load subscription status.
- Fork 15k
Description
I just came across an incompatibility between the new readability-redundant-member-init check and the -Wmissing-field-initializers diagnostic. It is a common pattern to have an aggregate type representing a set of options, some of which are optional, e.g.:
struct options {
int required_1;
int required_2;
std::optional<int> optional{};
};Now, if I have the following:
void foo(options opts);
void bar() {
foo({
.required_1 = 4,
.required_2 = 2,
// optional omitted.
});
}readability-redundant-member-init will complain the initializer for optional is redundant. However, if I remove it, -Wmissing-field-initializers will complain that the field initializer for optional is missing.
Compiler Explorer repro: https://godbolt.org/z/xfzPv8h47
Is there a way to make these two agree? Or maybe readability-redundant-member-init needs a new option or adjustment?