@@ -16,15 +16,21 @@ namespace test_mi_debug {
1616
1717struct Base0 {
1818 virtual ~Base0 () = default ;
19+ Base0 () = default ;
20+ Base0 (const Base0 &) = delete ;
1921};
2022
2123struct Base1 {
2224 virtual ~Base1 () = default ;
2325 std::vector<int > vec = {1 , 2 , 3 , 4 , 5 };
26+ Base1 () = default ;
27+ Base1 (const Base1 &) = delete ;
2428};
2529
2630struct Derived : Base1, Base0 {
2731 ~Derived () override = default ;
32+ Derived () = default ;
33+ Derived (const Derived &) = delete ;
2834};
2935
3036} // namespace test_mi_debug
@@ -50,10 +56,27 @@ TEST_SUBMODULE(mi_debug, m) {
5056
5157 m.def (" make_derived_as_base0" , []() -> std::shared_ptr<Base0> {
5258 auto ret_der = std::make_shared<Derived>();
59+ printf (" \n LOOOK [%lu] %s:%d\n " , (std::size_t ) ret_der.get (), __FILE__, __LINE__);
60+ fflush (stdout);
5361 auto ret = std::dynamic_pointer_cast<Base0>(ret_der);
62+ printf (" \n LOOOK [%lu] %s:%d\n " , (std::size_t ) ret.get (), __FILE__, __LINE__);
63+ fflush (stdout);
5464 return ret;
5565 });
5666
67+ m.def (
68+ " make_derived_as_base0_raw_ptr" ,
69+ []() {
70+ auto ret_der = new Derived{};
71+ printf (" \n LOOOK [%lu] %s:%d\n " , (std::size_t ) ret_der, __FILE__, __LINE__);
72+ fflush (stdout);
73+ auto ret = dynamic_cast <Base0 *>(ret_der);
74+ printf (" \n LOOOK [%lu] %s:%d\n " , (std::size_t ) ret, __FILE__, __LINE__);
75+ fflush (stdout);
76+ return ret;
77+ },
78+ py::return_value_policy::take_ownership);
79+
5780 // class_ OK
5881 // classh FAIL
5982 m.def (" get_vec_size_raw_ptr_base0" , [](const Base0 *obj) -> std::size_t {
@@ -66,7 +89,11 @@ TEST_SUBMODULE(mi_debug, m) {
6689
6790 // class_ OK
6891 // classh FAIL
69- m.def (" get_vec_size_raw_ptr_derived" , [](const Derived *obj) { return obj->vec .size (); });
92+ m.def (" get_vec_size_raw_ptr_derived" , [](const Derived *obj) {
93+ printf (" \n LOOOK [%lu] %s:%d\n " , (std::size_t ) obj, __FILE__, __LINE__);
94+ fflush (stdout);
95+ return obj->vec .size ();
96+ });
7097
7198 // class_ OK
7299 // classh FAIL
0 commit comments