[clang] [clang][bytecode] Check destination size when initializing from an array initlist (PR #196916)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Wed May 13 21:54:52 PDT 2026
================
@@ -1197,6 +1197,26 @@ namespace vdtor {
static_assert(vdtor_3(3) == 3);
}
+namespace ArrayDestSize {
+ template<typename T>
+ constexpr T dynarray(int elems, int i) {
+ T *p;
+ if constexpr (sizeof(T) == 1)
+ p = new T[elems]{"fox"}; // both-note {{evaluated array bound 3 is too small to hold 4 explicitly initialized elements}}
+ else
+ p = new T[elems]{1, 2, 3}; // both-note {{evaluated array bound 2 is too small to hold 3 explicitly initialized elements}}
+ T n = p[i]; // both-note 4{{past-the-end}}
----------------
tbaederr wrote:
No, the past-the-end things are already properly diagnosed before.
https://github.com/llvm/llvm-project/pull/196916
More information about the cfe-commits
mailing list