diff --git a/SWIG/Examples/test-suite/primitive_types.i b/SWIG/Examples/test-suite/primitive_types.i index 5aeb60f6a..fb57f4611 100644 --- a/SWIG/Examples/test-suite/primitive_types.i +++ b/SWIG/Examples/test-suite/primitive_types.i @@ -343,6 +343,47 @@ macro(size_t, pfx, sizet) #endif %inline { + struct Foo + { + int _a; + + Foo (int a) : _a(a) + { + } + + Foo(const Foo&) + { + } + ; + + Foo copy(Foo x) + { + return x; + } + + const Foo copy_c(const Foo x) + { + return x; + } + + const Foo& copy_r(const Foo& x) + { + return x; + } + + Foo* this_p() + { + return this; + } + + Foo& this_r() + { + return *this; + } + + }; + + struct Test { Test() diff --git a/SWIG/Lib/python/pyswigtype.swg b/SWIG/Lib/python/pyswigtype.swg index 2b0fd0069..ed9d0a195 100644 --- a/SWIG/Lib/python/pyswigtype.swg +++ b/SWIG/Lib/python/pyswigtype.swg @@ -64,7 +64,7 @@ %typemap(out) SWIGTYPE { $&1_ltype resultptr; - resultptr = new $1_ltype(($1_ltype &) $1); + resultptr = new $1_ltype(static_cast<$1_type &>($1)); $result = SWIG_NewPointerObj((void *)(resultptr), $&1_descriptor, 1); } #else