Closed
Description
Given a virtual function meant to return new instances of a type via a pointer to a base class, and a derived type declared in python, the return value cast won't keep the python object alive, resulting in a failure when attempting to call the virtual method on the new instance via the pointer. Because this function is called from c++, the return value policy has no effect.
Reproducible example code
https://github.com/yeswalrus/pybind11/tree/virtual-vector-return