[libcxx-commits] [PATCH] D151304: [libcxx] [test] Fix the new alloc tests for Windows

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed May 24 00:56:40 PDT 2023


mstorsjo created this revision.
mstorsjo added a reviewer: ldionne.
Herald added a project: All.
mstorsjo requested review of this revision.
Herald added a project: libc++.
Herald added a reviewer: libc++.

Use ASSERT_WITH_OPERATOR_NEW_FALLBACKS where relevant to waive
the known cases where operator new isn't overridden as expected,
in MinGW DLL configurations.

Clarify the reason for why the fallback in
new.delete.array/new.size_align_nothrow.replace.indirect doesn't
work as expected (which could be considered a vcruntime bug).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151304

Files:
  libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_align.replace.indirect.pass.cpp
  libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_align_nothrow.replace.indirect.pass.cpp
  libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_nothrow.replace.indirect.pass.cpp
  libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.size_align_nothrow.replace.indirect.pass.cpp


Index: libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.size_align_nothrow.replace.indirect.pass.cpp
===================================================================
--- libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.size_align_nothrow.replace.indirect.pass.cpp
+++ libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.size_align_nothrow.replace.indirect.pass.cpp
@@ -22,9 +22,6 @@
 // nor does the dynamic library shipped with z/OS.
 // UNSUPPORTED: target={{.+}}-zos{{.*}}
 
-// TODO: Investigate why this fails on MinGW-shared
-// UNSUPPORTED: target={{.+}}-windows-gnu
-
 #include <new>
 #include <cstddef>
 #include <cstdlib>
@@ -57,7 +54,7 @@
     {
         new_called = delete_called = 0;
         OverAligned* x = new (std::nothrow) OverAligned;
-        assert(static_cast<void*>(x) == DummyData);
+        ASSERT_WITH_OPERATOR_NEW_FALLBACKS(static_cast<void*>(x) == DummyData);
         ASSERT_WITH_OPERATOR_NEW_FALLBACKS(new_called == 1);
 
         delete x;
Index: libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_nothrow.replace.indirect.pass.cpp
===================================================================
--- libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_nothrow.replace.indirect.pass.cpp
+++ libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_nothrow.replace.indirect.pass.cpp
@@ -14,7 +14,8 @@
 // XFAIL: libcpp-no-vcruntime
 // XFAIL: LIBCXX-AIX-FIXME
 
-// TODO: Investigate why this fails on Windows
+// MSVC/vcruntime falls back from the nothrow array new to the nothrow
+// scalar new, instead of falling back on the throwing array new.
 // XFAIL: target={{.+}}-windows-msvc
 
 #include <new>
Index: libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_align_nothrow.replace.indirect.pass.cpp
===================================================================
--- libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_align_nothrow.replace.indirect.pass.cpp
+++ libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_align_nothrow.replace.indirect.pass.cpp
@@ -23,9 +23,6 @@
 // nor does the dynamic library shipped with z/OS.
 // UNSUPPORTED: target={{.+}}-zos{{.*}}
 
-// TODO: Investigate why this fails on MinGW-shared
-// UNSUPPORTED: target={{.+}}-windows-gnu
-
 #include <new>
 #include <cstddef>
 #include <cstdlib>
@@ -58,7 +55,7 @@
     {
         new_called = delete_called = 0;
         OverAligned* x = new (std::nothrow) OverAligned[3];
-        assert(static_cast<void*>(x) == DummyData);
+        ASSERT_WITH_OPERATOR_NEW_FALLBACKS(static_cast<void*>(x) == DummyData);
         ASSERT_WITH_OPERATOR_NEW_FALLBACKS(new_called == 1);
 
         delete[] x;
Index: libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_align.replace.indirect.pass.cpp
===================================================================
--- libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_align.replace.indirect.pass.cpp
+++ libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_align.replace.indirect.pass.cpp
@@ -22,9 +22,6 @@
 // nor does the dynamic library shipped with z/OS.
 // UNSUPPORTED: target={{.+}}-zos{{.*}}
 
-// TODO: Investigate why this fails on MinGW-shared
-// UNSUPPORTED: target={{.+}}-windows-gnu
-
 #include <new>
 #include <cstddef>
 #include <cstdlib>
@@ -58,11 +55,11 @@
     {
         new_called = delete_called = 0;
         OverAligned* x = new OverAligned[3];
-        assert(static_cast<void*>(x) == DummyData);
-        assert(new_called == 1);
+        ASSERT_WITH_OPERATOR_NEW_FALLBACKS(static_cast<void*>(x) == DummyData);
+        ASSERT_WITH_OPERATOR_NEW_FALLBACKS(new_called == 1);
 
         delete[] x;
-        assert(delete_called == 1);
+        ASSERT_WITH_OPERATOR_NEW_FALLBACKS(delete_called == 1);
     }
 
     // Test with a type that is right on the verge of being overaligned


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151304.525046.patch
Type: text/x-patch
Size: 4166 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230524/35d33e72/attachment.bin>


More information about the libcxx-commits mailing list