diff --git a/tests/src/unit-allocator.cpp b/tests/src/unit-allocator.cpp index 8fa9034b5..ca215751e 100644 --- a/tests/src/unit-allocator.cpp +++ b/tests/src/unit-allocator.cpp @@ -1073,10 +1073,12 @@ struct sweep_allocator return (std::numeric_limits::max)() / sizeof(T); } + // p may point to a const object when libc++ probes whether construct() is + // usable for copying, which static_cast(p) would not accept template - void construct(U* p, Args&& ... args) noexcept(noexcept(::new (static_cast(p)) U(std::forward(args)...))) + void construct(U* p, Args&& ... args) noexcept(noexcept(::new (const_cast(static_cast(p))) U(std::forward(args)...))) { - ::new (static_cast(p)) U(std::forward(args)...); + ::new (const_cast(static_cast(p))) U(std::forward(args)...); } template