summaryrefslogtreecommitdiff
path: root/clang/test/AST/ByteCode/new-delete.cpp
diff options
context:
space:
mode:
authorTimm Baeder <tbaeder@redhat.com>2025-09-24 14:48:38 +0200
committerGitHub <noreply@github.com>2025-09-24 14:48:38 +0200
commitd94a8282fbc60bcbb94732f06c98b93a7b09a35f (patch)
treeb3c46b82cae08f70aa8cb6d6d5a9070b51b91eb4 /clang/test/AST/ByteCode/new-delete.cpp
parent2d6ce5148cf144ab800116e1f75a5d007e82cf58 (diff)
[clang][bytecode] Don't crash on a null Descriptor (#160506)
... for dynamic memory allocation. This happens when the requested array size is too large. Fixes #152951
Diffstat (limited to 'clang/test/AST/ByteCode/new-delete.cpp')
-rw-r--r--clang/test/AST/ByteCode/new-delete.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/test/AST/ByteCode/new-delete.cpp b/clang/test/AST/ByteCode/new-delete.cpp
index af747d7a15b1..f54854070573 100644
--- a/clang/test/AST/ByteCode/new-delete.cpp
+++ b/clang/test/AST/ByteCode/new-delete.cpp
@@ -1091,6 +1091,19 @@ namespace NewNegSizeNothrow {
static_assert(test_nothrow_neg_size(), "expected nullptr");
} // namespace NewNegSizeNothrow
+#if __SIZEOF_SIZE_T == 8
+/// We can't allocate the array here as it is too big.
+/// Make sure we're not crashing by assuming an non-null
+/// Descriptor.
+namespace HugeAllocation {
+ void *p;
+ void foo ()
+ {
+ p = new char [256][256][256][256][256];
+ }
+}
+#endif
+
#else
/// Make sure we reject this prior to C++20
constexpr int a() { // both-error {{never produces a constant expression}}