[clang] [C] Do not diagnose flexible array members with -Wdefault-const-init-field-unsafe (PR #140578)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Tue May 20 03:59:21 PDT 2025
================
@@ -85,3 +85,33 @@ void func() {
static const int b; // zero-init-var-warning {{default initialization of an object of type 'const int' is incompatible with C++}} \
cxx-error {{default initialization of an object of const type 'const int'}}
}
+
+// Test the behavior of flexible array members. Those cannot be initialized
+// when a stack-allocated object of the structure type is created. We handle
+// degenerate flexible arrays similarly, but only if the array does not
+// actually specify any storage. Note that C++ does not have flexible array
+// members at all, which is why the test is disabled there.
+#ifndef __cplusplus
+struct RealFAM {
----------------
AaronBallman wrote:
That's a good idea, I'll add a test
https://github.com/llvm/llvm-project/pull/140578
More information about the cfe-commits
mailing list