================
@@ -3375,6 +3377,32 @@ InitListChecker::CheckDesignatedInitializer(const 
InitializedEntity &Entity,
     DesignatedEndIndex.setIsUnsigned(true);
   }
 
+  // The semantic form of an initializer list stores one pointer for every
+  // array element, including the elements omitted before a designator. Compute
+  // the required number of elements in a wider type so adding one cannot
+  // overflow.
+  llvm::APSInt NumInits = DesignatedEndIndex;
+  NumInits.setIsUnsigned(true);
+  NumInits = NumInits.extend(NumInits.getBitWidth() + 1);
+  ++NumInits;
+
+  // Keep a non-configurable ceiling so even an excessive command-line limit
+  // cannot request an initializer list too large for an unsigned-sized
+  // allocation.
----------------
erichkeane wrote:

We typically don't do this.  IF a user sets this too high and we crash, so be 
it.

https://github.com/llvm/llvm-project/pull/205503
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to