Add another no-destructor workaround.

This commit is contained in:
Ralf W. Grosse-Kunstleve 2022-07-18 11:48:46 -07:00
parent 7dc2cdbf9f
commit 2550aca34e
2 changed files with 8 additions and 4 deletions

View File

@ -269,9 +269,7 @@ TEST_SUBMODULE(builtin_casters, m) {
m.def( m.def(
"int_string_pair", "int_string_pair",
[]() { []() {
// Using no-destructor idiom to side-step overzealous MINGW GNU 12.1.0 // Using no-destructor idiom to side-step warnings from overzealous compilers.
// 'void operator delete(void*)' called on unallocated object 'int_string_pair'
// warning (observed with windows-latest mingw32, mingw64 @ 2022-07-18).
static auto *int_string_pair = new std::pair<int, std::string>{2, "items"}; static auto *int_string_pair = new std::pair<int, std::string>{2, "items"};
return int_string_pair; return int_string_pair;
}, },

View File

@ -178,7 +178,13 @@ TEST_SUBMODULE(stl, m) {
// Unnumbered regression (caused by #936): pointers to stl containers aren't castable // Unnumbered regression (caused by #936): pointers to stl containers aren't castable
static std::vector<RValueCaster> lvv{2}; static std::vector<RValueCaster> lvv{2};
m.def( 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<RValueCaster>{2};
return lvv;
},
py::return_value_policy::reference);
// test_deque // test_deque
m.def("cast_deque", []() { return std::deque<int>{1}; }); m.def("cast_deque", []() { return std::deque<int>{1}; });