[clang] [Clang][Bytecode] Fix void*-to-ptr casts originating from new/new[] (PR #174132)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 1 23:42:24 PST 2026
================
@@ -9,6 +9,17 @@ namespace VoidCast {
constexpr void* p = nullptr;
constexpr int* q = static_cast<int*>(p);
static_assert(q == nullptr);
+
+ static_assert((delete (int*)(void*)new int, true));
+ static_assert((delete[] (int*)(void*)new int[2], true));
+
+ // both-error at +2 {{not an integral constant expression}}
+ // both-note at +1 {{cast from 'void *' is not allowed in a constant expression because the pointed object type 'int' is not similar to the target type 'float'}}
+ static_assert((delete (float*)(void*)new int, true));
----------------
tbaederr wrote:
Move the expected output to the end of the `static_assert` line, like the others in this file.
https://github.com/llvm/llvm-project/pull/174132
More information about the cfe-commits
mailing list