[C++-sig] Boost.Python and GCC 3.4.2

Patrick Hartling patrick.hartling at gmail.com
Wed Sep 29 17:16:21 CEST 2004


I am running into a problem compiling Boost.Python using GCC 3.4.2.  I
get the following error using Boost.Python from CVS as of today:

gcc-C++-action bin/boost/libs/python/build/libboost_python.so/gcc/debug/shared-linkable-true/numeric.o
In file included from
/home/patrick/src/Boost/boost-cvs/boost/python/object/make_instance.hpp:9,
                 from
/home/patrick/src/Boost/boost-cvs/boost/python/object/make_ptr_instance.hpp:8,
                 from
/home/patrick/src/Boost/boost-cvs/boost/python/to_python_indirect.hpp:11,
                 from
/home/patrick/src/Boost/boost-cvs/boost/python/converter/arg_to_python.hpp:10,
                 from
/home/patrick/src/Boost/boost-cvs/boost/python/call.hpp:15,
                 from
/home/patrick/src/Boost/boost-cvs/boost/python/object_core.hpp:12,
                 from
/home/patrick/src/Boost/boost-cvs/boost/python/object.hpp:9,
                 from
/home/patrick/src/Boost/boost-cvs/boost/python/tuple.hpp:10,
                 from
/home/patrick/src/Boost/boost-cvs/boost/python/numeric.hpp:10,
                 from
/home/patrick/src/Boost/boost-cvs/libs/python/build/../src/numeric.cpp:6:
/home/patrick/src/Boost/boost-cvs/boost/python/object/instance.hpp:44:
error: a casts to a type other than an integral or enumeration type
cannot appear in a constant-expression
/home/patrick/src/Boost/boost-cvs/boost/python/object/instance.hpp:44:
error: '->' cannot appear in a constant-expression
/home/patrick/src/Boost/boost-cvs/boost/python/object/instance.hpp:44:
error: `&' cannot appear in a constant-expression
In file included from
/home/patrick/src/Boost/boost-cvs/boost/python/converter/registry.hpp:9,
                 from
/home/patrick/src/Boost/boost-cvs/boost/python/converter/registered.hpp:8,
                 from
/home/patrick/src/Boost/boost-cvs/boost/python/object/make_instance.hpp:10,
                 from
/home/patrick/src/Boost/boost-cvs/boost/python/object/make_ptr_instance.hpp:8,
                 from
/home/patrick/src/Boost/boost-cvs/boost/python/to_python_indirect.hpp:11,
                 from
/home/patrick/src/Boost/boost-cvs/boost/python/converter/arg_to_python.hpp:10,
                 from
/home/patrick/src/Boost/boost-cvs/boost/python/call.hpp:15,
                 from
/home/patrick/src/Boost/boost-cvs/boost/python/object_core.hpp:12,
                 from
/home/patrick/src/Boost/boost-cvs/boost/python/object.hpp:9,
                 from
/home/patrick/src/Boost/boost-cvs/boost/python/tuple.hpp:10,
                 from
/home/patrick/src/Boost/boost-cvs/boost/python/numeric.hpp:10,
                 from
/home/patrick/src/Boost/boost-cvs/libs/python/build/../src/numeric.cpp:6:
/home/patrick/src/Boost/boost-cvs/boost/python/converter/rvalue_from_python_data.hpp:99:
error: '->' cannot appear in a constant-expression
/home/patrick/src/Boost/boost-cvs/boost/python/converter/rvalue_from_python_data.hpp:99:
error: `&' cannot appear in a constant-expression
/home/patrick/src/Boost/boost-cvs/boost/python/converter/rvalue_from_python_data.hpp:99:
error: template argument 1 is invalid
/home/patrick/src/Boost/boost-cvs/boost/python/converter/rvalue_from_python_data.hpp:99:
error: `value' is not a member of `<declaration error>'

    set -e 
    "g++"   -c -Wall -ftemplate-depth-255  -DBOOST_PYTHON_DYNAMIC_LIB
-DBOOST_PYTHON_SOURCE  -g -O0 -fno-inline -fPIC  
-I"bin/boost/libs/python/build"   -I "/usr/local/include/python2.3" -I
"/home/patrick/src/Boost/boost-cvs"  -o
"bin/boost/libs/python/build/libboost_python.so/gcc/debug/shared-linkable-true/numeric.o"
 "/home/patrick/src/Boost/boost-cvs/libs/python/build/../src/numeric.cpp"

The code that GCC is complaining about is the type cast in the last
term of the last statement in the following:

template <class Data>
struct additional_instance_size
{
    typedef instance<Data> instance_data;
    typedef instance<char> instance_char;
    static const std::size_t value = sizeof(instance_data) -
((size_t)(&((instance_char *)0)->storage));


};

I haven't run into this problem before, and I am not sure how to go
about fixing it (and submitting a patch if appropriate).  I did find a
semi-related discussion on another mailing list with a reference to
the relevant part of the C++ Standard:

   http://www.cygwin.com/ml/ecos-discuss/2003-02/msg00214.html

I have seen reports from other people on this list saying that they
are using GCC 3.4 to compile Boost.Python without problems, so I may
be doing something wrong.  I have attached some simple test code that
reproduces the compiler error.  Is there a way to work around this, or
is it a GCC bug?

In case it makes a difference, here are the OS and compiler details:

> uname -mrs
FreeBSD 5.3-BETA5 i386
> g++ -v
Using built-in specs.
Configured with: FreeBSD/i386 system compiler
Thread model: posix
gcc version 3.4.2 [FreeBSD] 20040728

 -Patrick


-- 
Patrick L. Hartling
Research Assistant, VRAC
http://www.137.org/patrick/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: const-exp.cpp
Type: application/octet-stream
Size: 229 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20040929/f11bcfcb/attachment.obj>


More information about the Cplusplus-sig mailing list