================ @@ -0,0 +1,15 @@ +// RUN: not %clang_cc1 -std=c++20 -fsyntax-only %s 2>&1 \ +// RUN: | FileCheck %s --implicit-check-not='Assertion `NumElements.isPositive()` failed' + +// In C++20, constexpr dynamic allocation is permitted *only* if valid. +// A negative element count must be diagnosed (and must not crash). + +constexpr void f_bad_neg() { + int a = -1; + (void) new int[a]; // triggers negative-size path in the interpreter +} ---------------- snarang181 wrote:
Added https://github.com/llvm/llvm-project/pull/155737 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits