Hi,
I discovered some strange generation when using the following simplified interface. The generated code cannot be compiled because some reference is created without assignment, see below for more details.
%module test %inline %{ template<class T> class Vector { public: typedef T value; typedef value const & const_ref; Vector(const_ref A) { } ~Vector() { } }; enum TestEnum; %} %template(VecTestNum) Vector<TestEnum>;
Generates some strange new function:
SWIGINTERN PyObject *_wrap_new_VecTestNum(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Vector< enum TestEnum >::value *arg1 = 0 ; int val1 ; int ecode1 ; Vector< enum TestEnum >::const_ref temp1 ; /* here a const ref without definition of the variable will be created */ PyObject * obj0 = 0 ; Vector< TestEnum > *result = 0 ; ...
Swig version: 2.0.10
Swig command: swig -python -c++ test.i
Could be same issue as https://sourceforge.net/p/swig/bugs/1304/. The snippet was working with 2.0.1, but not with 2.0.10. It seems the patch didn't find the way to 2.0.10, if it's the same issue.
Reproduced with SWIG git master.
Still reproduces with current git master (b18b75369cd4b2795abad1283629b13a62630b58)
(Though the testcase needs tweaking slightly to actually define the enum (e.g.
enum TestEnum { TESTENUM };
) or else compilation gives an error:with that adjustment the generated wrapper fails to compile with:
)
Last edit: Olly Betts 2023-01-08