Using swig 1.3.35 the python interface generated for this c++ code:
class foo
{
private:
const foo& operator=(const foo&);
};
foo bar[16];
will generate the __wrap.cxx file containing:
SWIGINTERN int Swig_var_bar_set(PyObject *_val) {
{
foo *inp = 0;
int res = SWIG_ConvertPtr(_val, SWIG_as_voidptrptr(&inp),
SWIGTYPE_p_foo, 0 );
if (!SWIG_IsOK(res)) {
SWIG_exception_fail(SWIG_ArgError(res), "in variable '""bar""'
of type '""foo [16]""'");
} else if (inp) {
size_t ii = 0;
for (; ii < (size_t)16; ++ii) bar[ii] = inp[ii];
} else {
SWIG_exception_fail(SWIG_ValueError, "invalid null reference "
"in variable '""bar""' of type '""foo [16]""'");
}
}
return 0;
fail:
return 1;
}
which calls the private assignment operator of foo.
A fix for this would also take into account when the private assignment operator is inherited from another class.
Reproducible with current git master.
An assignment operator normally returns a non-const reference, but changing that doesn't help.
Here's a complete test case:
Fixed in https://github.com/swig/swig/commit/650aad82ede59abe1a9355c274e213d33ae9d543.