On Jun 6, 2013 10:40 AM, "David Abdurachmanov" <david.abd@gmail.com> wrote:
>
> Forgot to mention that code is compiled in C++11 mode.
>
> Failing generated code below
>
> 12813 SWIGINTERN PyObject *_wrap_PdgIdPairList_erase__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
> 12814   PyObject *resultobj = 0;
> 12815   std::vector< Rivet::PdgIdPair > *arg1 = (std::vector< Rivet::PdgIdPair > *) 0 ;
> 12816   SwigValueWrapper< std::vector< std::pair< int,int > >::iterator > arg2 ;
> 12817   void *argp1 = 0 ;
> 12818   int res1 = 0 ;
> 12819   swig::SwigPyIterator *iter2 = 0 ;
> 12820   int res2 ;
> 12821   PyObject * obj0 = 0 ;
> 12822   PyObject * obj1 = 0 ;
> 12823   SwigValueWrapper< std::vector< std::pair< int,int > >::iterator > result;
> 12824
> 12825   if (!PyArg_ParseTuple(args,(char *)"OO:PdgIdPairList_erase",&obj0,&obj1)) SWIG_fail;
> 12826   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__pairT_Rivet__PdgId_Rivet__PdgId_t_std__allocatorT_std__pairT_Rivet__PdgId_Rivet__PdgId_t_t_t, 0 |  0 );
> 12827   if (!SWIG_IsOK(res1)) {
> 12828     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PdgIdPairList_erase" "', argument " "1"" of type '" "std::vector< Rivet::PdgIdPair > *""'");
> 12829   }
> 12830   arg1 = reinterpret_cast< std::vector< Rivet::PdgIdPair > * >(argp1);
> 12831   res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
> 12832   if (!SWIG_IsOK(res2) || !iter2) {
> 12833     SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "PdgIdPairList_erase" "', argument " "2"" of type '" "std::vector< std::pair< int,int > >::iterator""'");
> 12834   } else {
> 12835     swig::SwigPyIterator_T<std::vector< std::pair< int,int > >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::vector< std::pair< int,int > >::iterator > *>(ite      r2);
> 12836     if (iter_t) {
> 12837       arg2 = iter_t->get_current();
> 12838     } else {
> 12839       SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "PdgIdPairList_erase" "', argument " "2"" of type '" "std::vector< std::pair< int,int > >::iterator""'")      ;
> 12840     }
> 12841   }
> 12842   result = (arg1)->erase(arg2);
> 12843   resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< std::pair< int,int > >::iterator & >(result)),
> 12844     swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
> 12845   return resultobj;
> 12846 fail:
> 12847   return NULL;
> 12848 }
>
> On Jun 6, 2013, at 10:17 AM, David Abdurachmanov wrote:
>
> > Hi,
> >
> > I am testing GCC 4.9.0 (r199649) w/ Rivet 1.8.2, which uses SWIG to generate a wrapper. GCC 4.9.0 fails to compile SWIG generated wrapper. Below you can find a log fragment [LOG_FRAGMENT] w/ errors.
> >
> > david
> >
> > <<LOG_FRAGMENT
> >
> > ./rivet/rivetwrap_wrap.cc: In function 'PyObject* _wrap_PdgIdPairList_erase__SWIG_0(PyObject*, PyObject*)':
> > ./rivet/rivetwrap_wrap.cc:12842:30: error: no matching function for call to 'std::vector<std::pair<int, int> >::erase(SwigValueWrapper<__gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > > >&)'
> >  result = (arg1)->erase(arg2);
> >                             ^
> > ./rivet/rivetwrap_wrap.cc:12842:30: note: candidates are:
> > In file included from /build/davidlt/490/test/slc6_amd64_gcc490/external/gcc/4.9.0/include/c++/4.9.0/vector:64:0,
> >                from /build/davidlt/490/test/BUILD/slc6_amd64_gcc490/external/rivet/1.8.2/Rivet-1.8.2/include/Rivet/RivetSTL.hh:11,
> >                from /build/davidlt/490/test/BUILD/slc6_amd64_gcc490/external/rivet/1.8.2/Rivet-1.8.2/include/Rivet/Rivet.hh:8,
> >                from /build/davidlt/490/test/BUILD/slc6_amd64_gcc490/external/rivet/1.8.2/Rivet-1.8.2/include/Rivet/Analysis.hh:5,
> >                from ./rivet/rivetwrap_wrap.cc:3088:
> > /build/davidlt/490/test/slc6_amd64_gcc490/external/gcc/4.9.0/include/c++/4.9.0/bits/stl_vector.h:1076:7: note: std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(std::vector<_Tp, _Alloc>::const_iterator) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > >; typename std::_Vector_base<_Tp, _Alloc>::pointer = std::pair<int, int>*; std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const std::pair<int, int>*, std::vector<std::pair<int, int> > >; typename __gnu_cxx::__alloc_traits<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_pointer = const std::pair<int, int>*]
> >      erase(const_iterator __position)
> >      ^
> > /build/davidlt/490/test/slc6_amd64_gcc490/external/gcc/4.9.0/include/c++/4.9.0/bits/stl_vector.h:1076:7: note:   no known conversion for argument 1 from 'SwigValueWrapper<__gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > > >' to 'std::vector<std::pair<int, int> >::const_iterator {aka __gnu_cxx::__normal_iterator<const std::pair<int, int>*, std::vector<std::pair<int, int> > >}'
> > /build/davidlt/490/test/slc6_amd64_gcc490/external/gcc/4.9.0/include/c++/4.9.0/bits/stl_vector.h:1103:7: note: std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::const_iterator) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > >; typename std::_Vector_base<_Tp, _Alloc>::pointer = std::pair<int, int>*; std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const std::pair<int, int>*, std::vector<std::pair<int, int> > >; typename __gnu_cxx::__alloc_traits<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_pointer = const std::pair<int, int>*]
> >      erase(const_iterator __first, const_iterator __last)
> >      ^
> > /build/davidlt/490/test/slc6_amd64_gcc490/external/gcc/4.9.0/include/c++/4.9.0/bits/stl_vector.h:1103:7: note:   candidate expects 2 arguments, 1 provided
> > ./rivet/rivetwrap_wrap.cc: In function 'PyObject* _wrap_PdgIdPairList_erase__SWIG_1(PyObject*, PyObject*)':
> > ./rivet/rivetwrap_wrap.cc:12895:35: error: no matching function for call to 'std::vector<std::pair<int, int> >::erase(SwigValueWrapper<__gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > > >&, SwigValueWrapper<__gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > > >&)'
> >  result = (arg1)->erase(arg2,arg3);
> >                                  ^
> > ./rivet/rivetwrap_wrap.cc:12895:35: note: candidates are:
> > In file included from /build/davidlt/490/test/slc6_amd64_gcc490/external/gcc/4.9.0/include/c++/4.9.0/vector:64:0,
> >                from /build/davidlt/490/test/BUILD/slc6_amd64_gcc490/external/rivet/1.8.2/Rivet-1.8.2/include/Rivet/RivetSTL.hh:11,
> >                from /build/davidlt/490/test/BUILD/slc6_amd64_gcc490/external/rivet/1.8.2/Rivet-1.8.2/include/Rivet/Rivet.hh:8,
> >                from /build/davidlt/490/test/BUILD/slc6_amd64_gcc490/external/rivet/1.8.2/Rivet-1.8.2/include/Rivet/Analysis.hh:5,
> >                from ./rivet/rivetwrap_wrap.cc:3088:
> > /build/davidlt/490/test/slc6_amd64_gcc490/external/gcc/4.9.0/include/c++/4.9.0/bits/stl_vector.h:1076:7: note: std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(std::vector<_Tp, _Alloc>::const_iterator) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > >; typename std::_Vector_base<_Tp, _Alloc>::pointer = std::pair<int, int>*; std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const std::pair<int, int>*, std::vector<std::pair<int, int> > >; typename __gnu_cxx::__alloc_traits<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_pointer = const std::pair<int, int>*]
> >      erase(const_iterator __position)
> >      ^
> > /build/davidlt/490/test/slc6_amd64_gcc490/external/gcc/4.9.0/include/c++/4.9.0/bits/stl_vector.h:1076:7: note:   candidate expects 1 argument, 2 provided
> > /build/davidlt/490/test/slc6_amd64_gcc490/external/gcc/4.9.0/include/c++/4.9.0/bits/stl_vector.h:1103:7: note: std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::const_iterator) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > >; typename std::_Vector_base<_Tp, _Alloc>::pointer = std::pair<int, int>*; std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const std::pair<int, int>*, std::vector<std::pair<int, int> > >; typename __gnu_cxx::__alloc_traits<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_pointer = const std::pair<int, int>*]
> >      erase(const_iterator __first, const_iterator __last)
> >      ^
> > /build/davidlt/490/test/slc6_amd64_gcc490/external/gcc/4.9.0/include/c++/4.9.0/bits/stl_vector.h:1103:7: note:   no known conversion for argument 1 from 'SwigValueWrapper<__gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > > >' to 'std::vector<std::pair<int, int> >::const_iterator {aka __gnu_cxx::__normal_iterator<const std::pair<int, int>*, std::vector<std::pair<int, int> > >}'
> > error: command 'gcc' failed with exit status 1
> > make[2]: *** [all-local] Error 1
> > make[2]: Leaving directory `/build/davidlt/490/test/BUILD/slc6_amd64_gcc490/external/rivet/1.8.2/Rivet-1.8.2/pyext'
> > make[1]: *** [all-recursive] Error 1
> > make[1]: Leaving directory `/build/davidlt/490/test/BUILD/slc6_amd64_gcc490/external/rivet/1.8.2/Rivet-1.8.2/pyext'
> > make: *** [all-recursive] Error 1
> > error: Bad exit status from /build/davidlt/490/test/tmp/rpm-tmp.MvhFgS (%build)
> >
> > LOG_FRAGMENT
>
>
> ------------------------------------------------------------------------------
I don't have gcc 4.9 to hand nor the code you are wrapping so can you provide more info...

- Does it also happen with gcc 4.8?
- Has it something to do with compiling gcc in c++11 mode?
- What combinations of Swig and gcc do work?
- How can this be easily replicated... A small test case would be preferable.

I note SwigValueWrapper in the generated code which is usually indicative of missing type info. However there should not be any regressions if it worked with earlier versions of Swig.

William