From ae937e5743ce78e97ac2e9983838eca69fbc3f15 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 17 Nov 2026 09:38:16 -0300 Subject: [PATCH] crypto: secp256k1_allocation's control calls operator new, which -O3 keeps The control was `delete new int(1)`, a new-expression whose allocation the standard lets the optimizer elide ([expr.new]); at variant=release, -O3 on wasip2 and wasip3 removed it, the counter did not move, and secp256k1_allocation and secp256k1_allocation_no_exceptions failed. A call of ::operator new is never elided, as webcpp::hash's allocation control already does. --- test/secp256k1_allocation_test.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/secp256k1_allocation_test.cpp b/test/secp256k1_allocation_test.cpp index 1660310f..9a760e48 100644 --- a/test/secp256k1_allocation_test.cpp +++ b/test/secp256k1_allocation_test.cpp @@ -68,9 +68,10 @@ class counting_resource final : public std::pmr::memory_resource { int main() { std::cout << "the C library's allocations counted: " << webcpp::test::c_allocations_counted << "\n"; - // The control: one operator new moves the counter. + // The control: one operator new moves the counter. A call of the function, not a + // new-expression, whose allocation the optimizer may elide ([expr.new]), as -O3 does. std::size_t const control = webcpp::test::allocations(); - delete new int(1); // NOLINT(cppcoreguidelines-owning-memory): the control's allocation + ::operator delete(::operator new(sizeof(int))); BOOST_TEST(webcpp::test::allocations() > control); counting_resource resource;