================
@@ -1069,6 +1069,30 @@ namespace BaseCompare {
static_assert(foo());
}
+
+namespace NegativeArraySize {
+
+constexpr void f() { // both-error {{constexpr function never produces a
constant expression}}
+ int x = -1;
+ int *p = new int[x]; //both-note {{cannot allocate array; evaluated array
bound -1 is negative}}
+}
+
+} // namespace NegativeArraySize
+
----------------
tbaederr wrote:
```suggestion
namespace NegativeArraySize {
constexpr void f() { // both-error {{constexpr function never produces a
constant expression}}
int x = -1;
int *p = new int[x]; //both-note {{cannot allocate array; evaluated array
bound -1 is negative}}
}
} // namespace NegativeArraySize
```
https://github.com/llvm/llvm-project/pull/155737
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits