[clang] [clang][Sema] Avoid out-of-memory crash on huge designated initializer indices (PR #205503)

Mariya Podchishchaeva via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 13 02:07:17 PDT 2026


================
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-unknown-unknown \
+// RUN:   -fmax-init-list-elements=4 %s
+
+int designated_at_limit[] = { [3] = 1 };
+_Static_assert(sizeof(designated_at_limit) / sizeof(int) == 4, "");
+
+int range_at_limit[] = { [1 ... 3] = 1 };
+_Static_assert(sizeof(range_at_limit) / sizeof(int) == 4, "");
+
+int designated_over_limit[] = {
+    [4] = 1, // expected-error {{array is too large (5 elements)}}
----------------
Fznamznon wrote:

That error is kind of weird now, should we add a new diagnostic message saying that the designated initializer is problematic? Probably up to @AaronBallman though

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


More information about the cfe-commits mailing list