[PATCH] D123649: Allow flexible array initialization in C++.

Eli Friedman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 17 12:22:20 PDT 2022


efriedma added inline comments.


================
Comment at: clang/lib/CodeGen/CodeGenModule.cpp:4639
+          getDataLayout().getTypeAllocSize(Init->getType()));
+      assert(VarSize == CstSize && "Emitted constant has unexpected size");
+#endif
----------------
ahatanak wrote:
> This assertion fails when the following code is compiled:
> 
> 
> ```
> typedef unsigned char uint8_t;
> typedef uint8_t uint8_a16 __attribute__((aligned(16)));
> 
> void foo1() {
>   static const uint8_a16 array1[] = { 1 };
> }
> ```
`sizeof(uint8_a16[1])` is 16, but we currently emit a one-byte global.  So it seems like there's an underlying bug exposed by the assertion.

gcc thinks this is nonsense, and just prints an error.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123649



More information about the cfe-commits mailing list