mirror of
https://github.com/pybind/pybind11.git
synced 2025-02-27 08:04:56 +00:00
Using no-destructor idiom to side-step overzealous MINGW warning.
This commit is contained in:
parent
e4cd663545
commit
449eb84acd
@ -266,9 +266,16 @@ TEST_SUBMODULE(builtin_casters, m) {
|
|||||||
});
|
});
|
||||||
m.def("lvalue_nested", []() -> const decltype(lvnested) & { return lvnested; });
|
m.def("lvalue_nested", []() -> const decltype(lvnested) & { return lvnested; });
|
||||||
|
|
||||||
static std::pair<int, std::string> int_string_pair{2, "items"};
|
|
||||||
m.def(
|
m.def(
|
||||||
"int_string_pair", []() { return &int_string_pair; }, py::return_value_policy::reference);
|
"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).
|
||||||
|
static auto *int_string_pair = new std::pair<int, std::string>{2, "items"};
|
||||||
|
return int_string_pair;
|
||||||
|
},
|
||||||
|
py::return_value_policy::reference);
|
||||||
|
|
||||||
// test_builtins_cast_return_none
|
// test_builtins_cast_return_none
|
||||||
m.def("return_none_string", []() -> std::string * { return nullptr; });
|
m.def("return_none_string", []() -> std::string * { return nullptr; });
|
||||||
|
Loading…
Reference in New Issue
Block a user