diff --git a/tests/test_builtin_casters.cpp b/tests/test_builtin_casters.cpp index 01f06f0b7..6ff63edfc 100644 --- a/tests/test_builtin_casters.cpp +++ b/tests/test_builtin_casters.cpp @@ -269,9 +269,7 @@ TEST_SUBMODULE(builtin_casters, m) { m.def( "int_string_pair", []() { - // Using no-destructor idiom to side-step overzealous MINGW GNU 12.1.0 - // 'void operator delete(void*)' called on unallocated object 'int_string_pair' - // warning (observed with windows-latest mingw32, mingw64 @ 2022-07-18). + // Using no-destructor idiom to side-step warnings from overzealous compilers. static auto *int_string_pair = new std::pair{2, "items"}; return int_string_pair; }, diff --git a/tests/test_stl.cpp b/tests/test_stl.cpp index 38d32fda9..dd118f63c 100644 --- a/tests/test_stl.cpp +++ b/tests/test_stl.cpp @@ -178,7 +178,13 @@ TEST_SUBMODULE(stl, m) { // Unnumbered regression (caused by #936): pointers to stl containers aren't castable static std::vector lvv{2}; m.def( - "cast_ptr_vector", []() { return &lvv; }, py::return_value_policy::reference); + "cast_ptr_vector", + []() { + // Using no-destructor idiom to side-step warnings from overzealous compilers. + static auto *lvv = new std::vector{2}; + return lvv; + }, + py::return_value_policy::reference); // test_deque m.def("cast_deque", []() { return std::deque{1}; });