[PATCH] D98363: [Sema] Fold VLA types in compound literals to constant arrays.

Eli Friedman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 15 14:11:45 PDT 2021


efriedma added inline comments.


================
Comment at: clang/test/Sema/vla.c:134
+  // expected-warning at +1{{variable length array folded to constant array as an extension}}
+  char (*a9)[] = (char[2][ksize]) {{1,2,3,4},{4,3,2,1}};
+
----------------
aaron.ballman wrote:
> efriedma wrote:
> > aaron.ballman wrote:
> > > Doesn't this violate the constraints in C17 6.5.2.5p1, "The type name shall specify a complete object type or an array of unknown size, but not a variable-length array type"?
> > Yes, this is a constraint violation.  This patch downgrades the error to a warning, for compatibility with older versions of clang.
> It was an error in older versions of Clang, so downgrading it to a warning can't make code *more* compatible with older versions. This also makes it harder to port C code to other compilers because Clang happily accepts code that the C standard says should be rejected.
> 
> I'm not strongly opposed to the change, but I also don't like ignoring constraint violations in the standard as that comes awfully close to what `-fpermissive` does (and at least with that awful flag you have to opt *into* the less strictly conforming behavior instead of getting it by default as with extensions).
> 
> I'm curious if @rsmith has thoughts here?
> It was an error in older versions of Clang

https://godbolt.org/z/rvbffY


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98363/new/

https://reviews.llvm.org/D98363



More information about the cfe-commits mailing list