Bugzilla – Bug 956
Bindings failure in core (traced-value) with older gcc
Last modified: 2010-08-07 08:18:57 UTC
I am trying building NS-3-dev (The GCC version is 4.1) First, my configure information: ./waf -d debug configure Checking for program gcc or cc : /usr/bin/gcc Checking for program cpp : /usr/bin/cpp Checking for program ar : /usr/bin/ar Checking for program ranlib : /usr/bin/ranlib Checking for gcc : ok Checking for program g++ or c++ : /usr/bin/g++ Checking for g++ : ok Checking for program pkg-config : /lusitania_homes/UniversidadDeExtremadura/javier.fernandez/bin/pkg-config-0.25/pkg-config Checking for regression reference traces : ok ../ns-3-dev-ref-traces (guessed) Checking for -Wl,--soname=foo support : yes Checking for header stdlib.h : yes Checking for header signal.h : yes Checking for header pthread.h : yes Checking for type uint128_t : not found Checking for type __uint128_t : yes Checking for high precision time implementation : 128-bit integer Checking for header stdint.h : yes Checking for header inttypes.h : yes Checking for header sys/inttypes.h : not found Checking for library rt : yes Checking for header netpacket/packet.h : yes Checking for header linux/if_tun.h : yes Package gtk+-2.0 was not found in the pkg-config search path. Perhaps you should add the directory containing `gtk+-2.0.pc' to the PKG_CONFIG_PATH environment variable No package 'gtk+-2.0' found Checking for pkg-config flags for GTK_CONFIG_STORE : not found Checking for pkg-config flags for LIBXML2 : ok Checking for library sqlite3 : yes Checking for NSC location : ok ../nsc (guessed) Checking for library dl : yes Checking for NSC supported architecture ia64 : ok Checking for header sys/socket.h : yes Checking for header netinet/in.h : yes Checking for program python : /lusitania_homes/UniversidadDeExtremadura/javier.fernandez/bin/Python-2.7/python Checking for Python version >= 2.3 : ok 2.7.0 Checking for library python2.7 : yes Checking for program python2.7-config : /lusitania_homes/UniversidadDeExtremadura/javier.fernandez/bin/Python-2.7/bin/python2.7-config Checking for header Python.h : yes Checking for -fvisibility=hidden support : yes Checking for pybindgen location : ok ../pybindgen (guessed) Checking for Python module pybindgen : ok Checking for pybindgen version : ok 0.14.1.764 Checking for types uint64_t and unsigned long equivalency : yes Checking for types uint64_t and unsigned long long equivalency : no Checking for the apidefs that can be used for Python bindings : gcc-LP64 Checking for Python module pygccxml : ok Checking for pygccxml version : ok 1.0.0 Checking for program gccxml : /lusitania_homes/UniversidadDeExtremadura/javier.fernandez/bin/gccxml-0.9.0+cvs20100501.orig/bin/gccxml Checking for gccxml version : ok 0.9.0 Checking for program mpic++ : /lusitania_homes/UniversidadDeExtremadura/javier.fernandez/bin/mpich/bin/mpic++ Checking for program sudo : /usr/bin/sudo Checking for program hg : /lusitania_homes/UniversidadDeExtremadura/javier.fernandez/bin/mercurial-1.6/hg Checking for program valgrind : not found Checking for pkg-config flags for GSL : ok Checking for -Wno-error=deprecated-declarations support : no Checking for -Wno-error=deprecated-declarations support : no Checking for -fstrict-aliasing support : yes Checking for -fstrict-aliasing support : yes Checking for -Wstrict-aliasing support : yes Checking for -Wstrict-aliasing support : yes ---- Summary of optional NS-3 features: Threading Primitives : enabled Real Time Simulator : enabled Emulated Net Device : enabled Tap Bridge : enabled GtkConfigStore : not enabled (library 'gtk+-2.0 >= 2.12' not found) XmlIo : enabled SQlite stats data output : enabled Network Simulation Cradle : enabled Python Bindings : enabled Python API Scanning Support : enabled MPI Support : not enabled (option --enable-mpi not selected) Use sudo to set suid bit : not enabled (option --enable-sudo not selected) Build examples and samples : enabled Static build : not enabled (option --enable-static not selected) GNU Scientific Library (GSL) : enabled Now, building problem: ./waf ......... [ 675/1346] cxx: src/internet-stack/ipv4-l3-protocol.cc -> build/debug/src/internet-stack/ipv4-l3-protocol_1.o ../src/internet-stack/tcp-typedefs.h:98: error: âSequenceNumber32â was not declared in this scope ../src/internet-stack/tcp-typedefs.h:98: error: template argument 1 is invalid ../src/internet-stack/tcp-typedefs.h:98: error: template argument 3 is invalid ../src/internet-stack/tcp-typedefs.h:98: error: template argument 4 is invalid ../src/internet-stack/tcp-typedefs.h:98: error: invalid type in declaration before â;â token ../src/internet-stack/pending-data.h:75: error: expected â,â or â...â before â&â token ../src/internet-stack/pending-data.h:75: error: ISO C++ forbids declaration of âSequenceNumber32â with no type ../src/internet-stack/pending-data.h:91: error: expected â,â or â...â before â&â token ../src/internet-stack/pending-data.h:91: error: ISO C++ forbids declaration of âSequenceNumber32â with no type ../src/internet-stack/pending-data.h:94: error: expected â,â or â...â before â&â token ../src/internet-stack/pending-data.h:94: error: ISO C++ forbids declaration of âSequenceNumber32â with no type ../src/internet-stack/pending-data.h:104: error: expected â,â or â...â before â&â token ../src/internet-stack/pending-data.h:104: error: ISO C++ forbids declaration of âSequenceNumber32â with no type ../src/internet-stack/rtt-estimator.h:42: error: expected `)' before âsâ ../src/internet-stack/rtt-estimator.h:45: error: âSequenceNumber32â does not name a type ../src/internet-stack/rtt-estimator.h:61: error: âSequenceNumber32â has not been declared ../src/internet-stack/rtt-estimator.h:62: error: âSequenceNumber32â has not been declared ........... ../src/internet-stack/tcp-header.cc:236: error: âm_ackNumberâ was not declared in this scope [ 676/1346] cxx: src/internet-stack/ipv4-end-point.cc -> build/debug/src/internet-stack/ipv4-end-point_1.o Waf: Leaving directory `/lusitania_homes/UniversidadDeExtremadura/javier.fernandez/bin/ns-3-dev/build' Build failed: -> task failed (err #1): {task: cxx tcp-header.cc -> tcp-header_1.o} Any idea for fix this problem? Thanks!
Sounds like the older sequence-number.h header file is being used instead of the new one. Could you try ./waf distclean and then build from scratch?
I have run: > ./waf clean > ./waf distclean > ./waf -d debug configure > ./waf and same error...
The old sequence-number.h file was still lying around. It should not have been included, this sounds like a compiler bug, but just in case I removed it from the tree. Otherwise I really don't know what to say. Probably a compiler bug? Maybe try with another compiler version to see if that's the cause?
I have updated the ns-3-dev repository and now it don´t start to build. > ./waf clean > ./waf distclean > ./waf configure > ./waf Waf: Entering directory `/bin/ns-3-dev/build' '/bin/ns-3-dev/bindings/python/ns3/__init__.py' -> '/bin/ns-3-dev/build/debug/bindings/python/ns3/__init__.py' Waf: Leaving directory `/bin/ns-3-dev/build' source not found: 'sequence-number.cc' in 'dir:///bin/ns-3-dev/src/internet-stack' I will try with another compiler version... Thanks.
There is something wrong in your tree; the wscript is referencing files, but those references should have been removed already... have you tried a fresh checkout?
OK!! The wscript file wasn´t updated because I modified it to "NSC" acept IA64 architecture. I deleted and re-updated it and the problem was fixed! But... Now I have another error: cc1plus: warnings being treated as errors debug/ns3/traced-value.h: In member function âns3::TracedValue<T>::operator ns3::EnumValue() const [with T = double]â: debug/bindings/python/ns3_module_core.cc:21494: instantiated from here debug/ns3/traced-value.h:88: warning: passing âconst doubleâ for argument 1 to âns3::EnumValue::EnumValue(int)â debug/ns3/traced-value.h: In member function âns3::TracedValue<T>::operator ns3::IntegerValue() const [with T = double]â: debug/bindings/python/ns3_module_core.cc:21848: instantiated from here debug/ns3/traced-value.h:73: warning: passing âconst doubleâ for argument 1 to âns3::IntegerValue::IntegerValue(const int64_t&)â debug/ns3/traced-value.h: In member function âns3::TracedValue<T>::operator ns3::UintegerValue() const [with T = double]â: debug/bindings/python/ns3_module_core.cc:25231: instantiated from here debug/ns3/traced-value.h:78: warning: passing âconst doubleâ for argument 1 to âns3::UintegerValue::UintegerValue(const uint64_t&)â [1201/1345] cxx: build/debug/bindings/python/ns3_module_energy.cc -> build/debug/bindings/python/ns3_module_energy_3.o Waf: Leaving directory `/bin/ns-3-dev/build' Build failed: -> task failed (err #1): {task: cxx ns3_module_core.cc -> ns3_module_core_3.o} Thanks.
(In reply to comment #6) > OK!! > The wscript file wasn´t updated because I modified it to "NSC" acept IA64 > architecture. I deleted and re-updated it and the problem was fixed! > > But... > Now I have another error: > > > cc1plus: warnings being treated as errors > debug/ns3/traced-value.h: In member function âns3::TracedValue<T>::operator > ns3::EnumValue() const [with T = double]â: > debug/bindings/python/ns3_module_core.cc:21494: instantiated from here > debug/ns3/traced-value.h:88: warning: passing âconst doubleâ for argument 1 to > âns3::EnumValue::EnumValue(int)â > debug/ns3/traced-value.h: In member function âns3::TracedValue<T>::operator > ns3::IntegerValue() const [with T = double]â: > debug/bindings/python/ns3_module_core.cc:21848: instantiated from here > debug/ns3/traced-value.h:73: warning: passing âconst doubleâ for argument 1 to > âns3::IntegerValue::IntegerValue(const int64_t&)â > debug/ns3/traced-value.h: In member function âns3::TracedValue<T>::operator > ns3::UintegerValue() const [with T = double]â: > debug/bindings/python/ns3_module_core.cc:25231: instantiated from here > debug/ns3/traced-value.h:78: warning: passing âconst doubleâ for argument 1 to > âns3::UintegerValue::UintegerValue(const uint64_t&)â > [1201/1345] cxx: build/debug/bindings/python/ns3_module_energy.cc -> > build/debug/bindings/python/ns3_module_energy_3.o > Waf: Leaving directory `/bin/ns-3-dev/build' > Build failed: -> task failed (err #1): > {task: cxx ns3_module_core.cc -> ns3_module_core_3.o} > > > Thanks. I can confirm this on g++-3.4 (GCC) 3.4.6 (Ubuntu 3.4.6-6ubuntu5)
I have gcc/g++ (GCC) 4.1.2 20070115 (SUSE Linux)
I can reproduce by compiling with GCC 4.1. Now this is a weird bug. traced-value.h contains: template <typename T> class TracedValue { [...] TracedValue (const EnumValue &value) : m_v (value.Get ()) {} operator EnumValue () const { return EnumValue (m_v); } [...] }; Consequently, the bindings apidefs contains: ## traced-value.h: ns3::TracedValue<double> [class] root_module['ns3::TracedValue< double >'].implicitly_converts_to(root_module['ns3::EnumValue']) And so, the generated constructor for ns3::TracedValue<double> contains: PyObject *arg0; ns3::EnumValue arg02; const char *keywords[] = {"arg0", NULL}; [...] if (PyObject_IsInstance(arg0, (PyObject*) &PyNs3EnumValue_Type)) { arg02 = *((PyNs3EnumValue *) arg0)->obj; } else if (PyObject_IsInstance(arg0, (PyObject*) &PyNs3TracedValue__Double_Type)) { arg02 = *((PyNs3TracedValue__Double *) arg0)->obj; ///// error here } else { [...] } self->obj = new ns3::EnumValue(arg02); return 0; } ((( "((PyNs3TracedValue__Double *) arg0)->obj" is of type ns3::TracedValue< double > * ))) So I really don't get the compiler error, the bindings code should be correct.
With template <typename T> class TracedValue { operator EnumValue () const { return EnumValue (m_v); } [...] T m_v; } With instantiation for double, it becomes: class TracedValue... { double m_v; operator EnumValue () const { return EnumValue (m_v); } } We are thus passing a double for a constructor accepting int. Loss of precision possible. The compiler warns. The templated code is too generic, it's not python bindings fault, I think. Mathieu?
I have builded other GCC version [4.3.3] and this problem is fixed, but I think is a possible bug...
(In reply to comment #10) > With > > template <typename T> > class TracedValue > { > operator EnumValue () const { > return EnumValue (m_v); > } > > [...] > T m_v; > } > > With instantiation for double, it becomes: > > class TracedValue... > { > double m_v; > operator EnumValue () const { > return EnumValue (m_v); > } > } > > We are thus passing a double for a constructor accepting int. Loss of > precision possible. The compiler warns. The templated code is too generic, > it's not python bindings fault, I think. > > Mathieu? I do not remember why this template bothers with defining these implicit conversion operators.
reopening-- this will affect gcc-4.1 or older machines (if we are still supporting those compilers, we need to fix this bindings issue)
Created attachment 958 [details] patch I tried removing some implicit constructor / conversion operator, and rescan python bindings, and then NS-3 builds fine with GCC 4.1. Mathieu, OK to apply the patch (except remove the lines instead of comment them) ?
I think that they are needed to be able to declare a TracedValue<int> as an attribute IntegerValue for example.
(In reply to comment #15) > I think that they are needed to be able to declare a TracedValue<int> as an > attribute IntegerValue for example. I'm not sure, but if true such functionality is not used currently in NS-3, because remove it and NS-3 builds fine.
(In reply to comment #16) > (In reply to comment #15) > > I think that they are needed to be able to declare a TracedValue<int> as an > > attribute IntegerValue for example. > > I'm not sure, but if true such functionality is not used currently in NS-3, > because remove it and NS-3 builds fine. yes, but once people start using TracedValue, they will get in this mess. Maybe it would work to add instead the conversion constructor and operator to the attribute classes instead ? say, BooleanValue, et al.
changeset 34e72f4cdd87