Some Warning at compile time

On MacOsX, with the svn trunk, I get :

clang++ -g -O2 -m64 -pipe -Wshadow -W -Wall -Woverloaded-virtual -fsigned-char -fno-common -Iinclude     -pthread -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -o bindings/pyroot/src/PropertyProxy.o -c /Users/couet/roottrunk/bindings/pyroot/src/PropertyProxy.cxx
/Users/couet/roottrunk/bindings/pyroot/src/MethodProxy.cxx:236:7: warning: array index of '1' indexes past the end
      of an array (that contains 1 elements) [-Warray-bounds]
      PyTuple_SET_ITEM( co_consts, 1, val1 );    
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/tupleobject.h:54:37: note: instantiated from:
#define PyTuple_SET_ITEM(op, i, v) (((PyTupleObject *)(op))->ob_item[i] = v)
                                    ^
/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/tupleobject.h:26:5: note: array 'ob_item'
      declared here
    PyObject *ob_item[1];
    ^
/Users/couet/roottrunk/bindings/pyroot/src/MethodProxy.cxx:240:7: warning: array index of '1' indexes past the end
      of an array (that contains 1 elements) [-Warray-bounds]
      PyTuple_SET_ITEM( co_names, 1, PyString_FromString( "acos" ) );    
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/tupleobject.h:54:37: note: instantiated from:
#define PyTuple_SET_ITEM(op, i, v) (((PyTupleObject *)(op))->ob_item[i] = v)
                                    ^
/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/tupleobject.h:26:5: note: array 'ob_item'
      declared here
    PyObject *ob_item[1];
    ^

Hi,

this is only with llvm, not with gcc, and is known for some time. However, since these macro’s come from Python itself, it can not be helped.

In any event, there is no actual problem, just the standard issue that Python is written in C, and C isn’t very flexible, resulting in code with plenty of void*'s (or equivalents) and casts. In this case, all container classes (including tuples) are structs in which the first portion of the object layout has to be the same to allow generic sequence functions to work on any kind of container. Hence the one-element ob_item that is part of that first portion and can thus be assumed to be available. The other elements needed, which are variable in number, are taken care of by the class-specific allocators.

Perhaps it is possible to remove -Warray-bounds for the PyROOT portion of the builds using clang?

Cheers,
Wim