-
Couldn't load subscription status.
- Fork 15k
Closed
Closed
Copy link
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerconfirmedVerified by a second partyVerified by a second party
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
| // Disable check for missing fields when designators are used. | |
| // This matches gcc behaviour. | |
| CheckForMissingFields = false; |
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.
Metadata
Metadata
Assignees
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerconfirmedVerified by a second partyVerified by a second party