Hi,

 

I'm working through the failing testcases for guile. One testcase fails with a compilation error in some generated code based on std_map and std_pair. I know exactly where this generated code comes from, but my C++ knowledge is insufficient to understand the error, let alone remedy it. I gather some kind of const violation, but that's all I can read from it :( My hope is that someone used to working with stl will more easily understand it.

 

So, if someone can help me understand the error and what the fix would be in C++, I can fix the corresponding .i file.

 

This is the code snippet the causes the error:

 

--------------

static SCM

_wrap_new_paircA1__SWIG_2 (int argc, SCM *argv)

{

#define FUNC_NAME "new-paircA1"

std::pair< int const,A * > *arg1 = 0 ;

std::pair< int const,A * > temp1 ;

std::pair< int const,A * > *m1 ;

SCM gswig_result;

SWIGUNUSED int gswig_list_p = 0;

std::pair< int const,A * > *result = 0 ;

{

if (scm_is_pair(argv[0])) {

int const* x;

A ** y;

SCM first, second;

first = SCM_CAR(argv[0]);

second = SCM_CDR(argv[0]);

x = (int const*) SWIG_MustGetPtr(first,SWIGTYPE_p_int,1, 0);

y = (A **) SWIG_MustGetPtr(second,SWIGTYPE_p_p_A,1, 0);

temp1 = std::make_pair(*x,*y);

arg1 = &temp1;

} else {

arg1 = (std::pair< int const,A * > *)

SWIG_MustGetPtr(argv[0],SWIGTYPE_p_std__pairT_int_const_A_p_t,1, 0);

}

}

result = (std::pair< int const,A * > *)new std::pair< int const,A * >((std::pair< int const,A * > const &)*arg1);

{

gswig_result = SWIG_NewPointerObj (result, SWIGTYPE_p_std__pairT_int_const_A_p_t, 1);

}

return gswig_result;

#undef FUNC_NAME

}

------------

 

And this is the error thrown by g++:

 

-------------

In file included from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/stl_algobase.h:65:0,

from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/char_traits.h:41,

from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/string:42,

from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/stdexcept:40,

from li_std_map_wrap.cxx:1334:

/usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/stl_pair.h: In member function ‘std::pair<const int, A*>& std::pair<const int, A*>::operator=(const std::pair<const int, A*>&)’:

/usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/stl_pair.h:88:12: error: non-static const member ‘const int std::pair<const int, A*>::first’, can’t use default assignment operator

li_std_map_wrap.cxx: In function ‘scm_unused_struct* _wrap_new_paircA1__SWIG_2(int, scm_unused_struct**)’:

li_std_map_wrap.cxx:7429:35: note: synthesized method ‘std::pair<const int, A*>& std::pair<const int, A*>::operator=(const std::pair<const int, A*>&)’ first required here

In file included from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/stl_algobase.h:65:0,

from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/char_traits.h:41,

from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/string:42,

from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/stdexcept:40,

from li_std_map_wrap.cxx:1334:

/usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/stl_pair.h: In member function ‘std::pair<const int, const A*>& std::pair<const int, const A*>::operator=(const std::pair<const int, const A*>&)’:

/usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/stl_pair.h:88:12: error: non-static const member ‘const int std::pair<const int, const A*>::first’, can’t use default assignment operator

li_std_map_wrap.cxx: In function ‘scm_unused_struct* _wrap_new_paircA2__SWIG_2(int, scm_unused_struct**)’:

li_std_map_wrap.cxx:7666:35: note: synthesized method ‘std::pair<const int, const A*>& std::pair<const int, const A*>::operator=(const std::pair<const int, const A*>&)’ first required here

In file included from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/stl_algobase.h:65:0,

from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/char_traits.h:41,

from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/string:42,

from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/stdexcept:40,

from li_std_map_wrap.cxx:1334:

/usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/stl_pair.h: In member function ‘std::pair<int, const std::pair<int, A*> >& std::pair<int, const std::pair<int, A*> >::operator=(const std::pair<int, const std::pair<int, A*> >&)’:

/usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/stl_pair.h:88:12: error: non-static const member ‘const std::pair<int, A*> std::pair<int, const std::pair<int, A*> >::second’, can’t use default assignment operator

li_std_map_wrap.cxx: In function ‘scm_unused_struct* _wrap_new_pairiiAc__SWIG_2(int, scm_unused_struct**)’:

li_std_map_wrap.cxx:8208:52: note: synthesized method ‘std::pair<int, const std::pair<int, A*> >& std::pair<int, const std::pair<int, A*> >::operator=(const std::pair<int, const std::pair<int, A*> >&)’ first required here

make[2]: *** [libli_std_map.so] Error 1

-----------

 

Thank you,

 

Geert