← Back to team overview

dolfin team mailing list archive

Removing a compiler warning

 

When trying to compile the (huge, swig-generated) file
dolfin/swig/dolfin_wrap.cc, my compiler (Apple-tainted g++ 4.0.x)
tends to complain:

dolfin/swig/dolfin_wrap.cc: In member function
'swig::PySequence_Ref<T>::operator T() const [with T = dolfin::uint]':
dolfin/swig/dolfin_wrap.cc:4039: warning: 'v' may be used
uninitialized in this function

And, since warnings are being treated as errors, the build fails. The
relevant section of the file reads as follows:

static Type as(PyObject *obj, bool throw_error) {
    Type v;
    int res = asval(obj, &v);
    ...

v is being set by passing it via reference elsewhere, but the compiler
doesn't seem to realise this. So far, I've gotten around this by just
editing one line to read:

Type v = 0;

I was wondering if someone with greater swig-fu skills than I could
take a look at the appopriate swig interface file and have it generate
this line instead, if it's a reasonable thing to do.

Harish