mirror of
https://github.com/pybind/pybind11.git
synced 2026-04-20 06:49:25 +00:00
Added a test to detect invalid RTTI caching
The current inheritance testing isn't sufficient to detect a cache failure; the test added here breaks PR #390, which caches the run-time-determined return type the first time a function is called, then reuses that cached type even though the run-time type could be different for a future call.
This commit is contained in:
@@ -77,5 +77,10 @@ test_initializer inheritance([](py::module &m) {
|
||||
|
||||
m.def("return_class_1", []() -> BaseClass* { return new DerivedClass1(); });
|
||||
m.def("return_class_2", []() -> BaseClass* { return new DerivedClass2(); });
|
||||
m.def("return_class_n", [](int n) -> BaseClass* {
|
||||
if (n == 1) return new DerivedClass1();
|
||||
if (n == 2) return new DerivedClass2();
|
||||
return new BaseClass();
|
||||
});
|
||||
m.def("return_none", []() -> BaseClass* { return nullptr; });
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user