#958 Error when compiling SWIG code, argv[0] may be uninitialized

open
nobody
python (259)
5
2012-12-21
2008-10-17
No

We are compiling the SWIG wrapper with -Werror. With gcc > 4.3, the builds are exiting with the following message:
dolfin/swig/dolfin_wrap.cc: In function 'PyObject*
_wrap_new_Mesh(PyObject*, PyObject*)':
dolfin/swig/dolfin_wrap.cc:69695: error: 'argv[0]' may be used
uninitialized in this function

If we substitute 'Type v;' with 'Type v=0;' the compilation is successfull. This seems to be the same error as described here:
http://thread.gmane.org/gmane.comp.programming.swig.devel/15799/focus=15809

I could not find a previous bug for this issue.

Sincerly, Ilmar

Discussion

  • William Fulton

    William Fulton - 2008-11-29

    Please provide a minimal test case as this problem cannot be replicated.

     
  • Andy Buckley

    Andy Buckley - 2009-12-18

    I'm also seeing this, with SWIG 1.3.36 (system version on Ubuntu Karmic). I'm building a Python interface, using Python distutils inside GNU autotools for compilation of SWIG-generated source rivet_wrap.cc. The Python (and distutils) version is Python 2.6.4 - again the Karmic system version. I don't have a minimal test case, but hopefully the following terminal output is useful:

    gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DSWIG_TYPE_TABLE=hepmccompat -I/home/andy/proj/hep/rivet/include -I/home/andy/heplocal/include -I/usr/include -I/usr/include -I/usr/include/python2.6 -c ./rivet_wrap.cc -o build/temp.linux-x86_64-2.6/./rivet_wrap.o
    cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
    ./rivet_wrap.cc: In function ‘PyObject* _wrap_Log_setUseColors(PyObject*, PyObject*)’:
    ./rivet_wrap.cc:8718: warning: ‘argv[0]’ may be used uninitialized in this function
    ./rivet_wrap.cc: In function ‘PyObject* _wrap_Log_setShowLoggerName(PyObject*, PyObject*)’:
    ./rivet_wrap.cc:8652: warning: ‘argv[0]’ may be used uninitialized in this function
    ./rivet_wrap.cc: In function ‘PyObject* _wrap_Log_setShowLevel(PyObject*, PyObject*)’:
    ./rivet_wrap.cc:8586: warning: ‘argv[0]’ may be used uninitialized in this function
    ./rivet_wrap.cc: In function ‘PyObject* _wrap_Log_setShowTimestamp(PyObject*, PyObject*)’:
    ./rivet_wrap.cc:8520: warning: ‘argv[0]’ may be used uninitialized in this function
    ./rivet_wrap.cc: In function ‘PyObject* _wrap_toString(PyObject*, PyObject*)’:
    ./rivet_wrap.cc:7258: warning: ‘argv[0]’ may be used uninitialized in this function
    ./rivet_wrap.cc: In function ‘PyObject* _wrap_new_LogLevelMap(PyObject*, PyObject*)’:
    ./rivet_wrap.cc:7802: warning: ‘argv[0]’ may be used uninitialized in this function
    g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions build/temp.linux-x86_64-2.6/./rivet_wrap.o -L/home/andy/proj/hep/rivet/src -L/home/andy/proj/hep/rivet/src/.libs -L/home/andy/heplocal/lib -lHepMC -lRivet -o build/lib.linux-x86_64-2.6/_rivet.so

    Most of these functions are static functions defined in a logging class, e.g.

    namespace Rivet {

    class Log {
    public:

    static void setShowTimestamp(const bool showTime=true) {
    showTimestamp = showTime;
    }

    static void setShowLevel(const bool showLevel=true) {
    showLogLevel = showLevel;
    }

    static void setShowLoggerName(const bool showName=true) {
    showLoggerName = showName;
    }

    static void setUseColors(const bool useColors=true) {
    useShellColors = useColors;
    }

    ...

    };

    }

    Hope that helps.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks