You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When moving from version 2.0.1 to 2.2.1, compiled using both visual studio 2015 and 2019, I encountered an error
Run-Time Check Failure #0 - The value of ESP was not properly
saved across a function call. This is usually a result of
calling a function declared with one calling convention with
a function pointer declared with a different calling convention.
in code that had virtual inheritance. Here is a simplified example that illustrates the issue:
struct A0 {
virtual int size() const = 0;
int non_virtual() const { return 2; }
};
struct A1 : public virtual A0 {
int size() const { return 1; }
};
inline void A_test(const A0& a) {
std::cout << a.non_virtual() << std::endl;
std::cout << a.size() << std::endl;
}
It seems I just need to change
class_<A1, A0>(m, "A1")
to
class_<A1, A0>(m, "A1", multiple_inheritance())
even though the eventual class that uses multiple inheritance is not wrapped.
I'm not sure why it worked in 2.0.1.
Regards,
jcr
When moving from version 2.0.1 to 2.2.1, compiled using both visual studio 2015 and 2019, I encountered an error
in code that had virtual inheritance. Here is a simplified example that illustrates the issue:
struct A0 {
virtual int size() const = 0;
int non_virtual() const { return 2; }
};
struct A1 : public virtual A0 {
int size() const { return 1; }
};
inline void A_test(const A0& a) {
std::cout << a.non_virtual() << std::endl;
std::cout << a.size() << std::endl;
}
PYBIND11_PLUGIN(virtual_test) {
pybind11::module m("virtual_test", "virtual test extension module");
pybind11::class_(m, "A0")
.def("size", &A0::size)
.def("non_virtual", &A0::non_virtual);
pybind11::class_<A1, A0>(m, "A1")
.def(py::init<>());
m.def("A_test", A_test);
}
and in the python script
a1 = A1()
A_test(a1)
print 'done'
With virtual inheritance, thd code only prints
2
then crashes, but correctly prints
2
1
done
when the virtual keyword is removed.
Thanks,
jcr
The text was updated successfully, but these errors were encountered: