[clang] [clang][CodeGen] Fix crash for VLA alias in local class constructor (PR #183933)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 8 18:29:55 PDT 2026


================
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=gnu++20 -emit-llvm %s -o - >/dev/null
+
+int f() { return 1; }
+
+int test0() {
+  using X = int[f()];
+
+  struct S {
+    S() {
+      X x;
----------------
efriedma-quic wrote:

I think we should be rejecting this in Sema; we can't correctly compute the size of a variably modified type from within a local class.

Consider a related example:

```
int f(int&);
struct IFace {
  virtual int a() = 0;
  virtual ~IFace();
};
IFace *test() {
  int z = 10;
  using X = int[f(z)];
  struct S : public IFace {
    int a() override { return sizeof(X); }
  };
  return new S;
}
```

How are we supposed to generate code for a() here?

https://github.com/llvm/llvm-project/pull/183933


More information about the cfe-commits mailing list