Index: libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow_replace.pass.cpp =================================================================== --- libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow_replace.pass.cpp +++ libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow_replace.pass.cpp @@ -50,11 +50,11 @@ DoNotOptimize(ap); assert(ap); assert(A_constructed == 3); - assert(new_called); + ASSERT_VIA_OVERRIDDEN_NEW(new_called); delete [] ap; DoNotOptimize(ap); assert(A_constructed == 0); - assert(!new_called); + ASSERT_VIA_OVERRIDDEN_DELETE(!new_called); return 0; } Index: libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_replace.pass.cpp =================================================================== --- libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_replace.pass.cpp +++ libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_replace.pass.cpp @@ -11,7 +11,6 @@ // UNSUPPORTED: sanitizer-new-delete // XFAIL: libcpp-no-vcruntime - #include #include #include @@ -51,11 +50,11 @@ DoNotOptimize(ap); assert(ap); assert(A_constructed == 3); - assert(new_called == 1); + ASSERT_VIA_OVERRIDDEN_NEW(new_called == 1); delete [] ap; DoNotOptimize(ap); assert(A_constructed == 0); - assert(new_called == 0); + ASSERT_VIA_OVERRIDDEN_DELETE(new_called == 0); return 0; } Index: libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow_replace.pass.cpp =================================================================== --- libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow_replace.pass.cpp +++ libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow_replace.pass.cpp @@ -50,11 +50,11 @@ DoNotOptimize(ap); assert(ap); assert(A_constructed); - assert(new_called); + ASSERT_VIA_OVERRIDDEN_NEW(new_called); delete ap; DoNotOptimize(ap); assert(!A_constructed); - assert(!new_called); + ASSERT_VIA_OVERRIDDEN_DELETE(!new_called); return 0; } Index: libcxx/test/support/test_macros.h =================================================================== --- libcxx/test/support/test_macros.h +++ libcxx/test/support/test_macros.h @@ -328,6 +328,18 @@ static_assert((test_macros_detail::is_same<__VA_ARGS__>::value), \ "Types differ unexpectedly") +// z/OS has different runtime linking model, references are determined at +// link step, C++RT new or new[] operator will call the new operator it knows +// about in shared library not the one user defined. Same with delete +// operator. +#if defined(__MVS__) +#define ASSERT_VIA_OVERRIDDEN_NEW(x) +#define ASSERT_VIA_OVERRIDDEN_DELETE(x) +#else +#define ASSERT_VIA_OVERRIDDEN_NEW(x) assert(x) +#define ASSERT_VIA_OVERRIDDEN_DELETE(x) assert(x) +#endif + #ifndef TEST_HAS_NO_EXCEPTIONS #define TEST_THROW(...) throw __VA_ARGS__ #else