Closed
Description
In the following code, the missing-field-initializers
does not produce a warning that b
is not explicitly initialized.
Changing CheckForMissingFields
to True
here:
llvm-project/clang/lib/Sema/SemaInit.cpp
Lines 2167 to 2169 in a9a60f2
seems to produce the expected warning.
The comment suggests
// Disable check for missing fields when designators are used.
// This matches gcc behaviour.
However, GCC does produce the warning in that case.
Comparison with GCC: https://godbolt.org/z/WeYdY11q3
struct ExampleStruct {
int a;
int b;
};
ExampleStruct buildExampleStruct(int a) {
ExampleStruct e{
.a=a
};
return e;
}
Build flags: -Werror=missing-field-initializers -std=c++20
Expected behavior:
main.cpp:10:5: error: missing field 'b' initializer [-Werror,-Wmissing-field-initializers]
matching GCCs
<source>:9:5: error: missing initializer for member 'ExampleStruct::b' [-Werror=missing-field-initializers]
Actual behavior: Compiles without warning/error.