[PATCH] Sema: Treat zero sized arrays as flexible array members

Richard Smith richard at metafoo.co.uk
Mon Sep 29 13:41:12 PDT 2014


It'd be useful to figure out where we differ from the GCC documentation with this patch applied:

https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html

================
Comment at: test/SemaCXX/zero-length-arrays.cpp:13
@@ -13,5 +12,3 @@
   int foo_count;
-  Foo foos[0];
-  Foo foos2[0][2];
-  Foo foos3[2][0];
+  Foo foos[0]; // expected-error-re {{flexible array member {{.*}} with non-trivial destruction}}
 
----------------
majnemer wrote:
> rsmith wrote:
> > Can we find out what rdar://problem/10228639 was?
> > interaction between having a trailing zero-sized array in a struct (C++ extension) and whether that implies having a default constructor.
> > the usual sort of thing. language extension interaction w/ actual language standard. things get odd.
Sounds like there was no expectation that we actually accept this then?

http://reviews.llvm.org/D5478






More information about the cfe-commits mailing list