Ben Webb | 3 Dec 02:59
Favicon

Bug in SWIG 1.3.35 with std::vector type system?

I have encountered a problem with SWIG 1.3.35 and later with a fairly
simple usage of std::vector. (I have opened a bug on the tracker
containing the same information, #2380788.) What seems to be happening
is that the SWIG runtime is getting confused about the type of the
std::vector.

For example, running 'make' with the following Makefile and test.i works
(produces no output from Python) with SWIG 1.3.34, but fails on SWIG
1.3.35, 1.3.36 and SVN r10960 with the error:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "test.py", line 130, in insert
    def insert(self, *args): return _test.vectorf_insert(self, *args)
NotImplementedError: Wrong number of arguments for overloaded function
'vectorf_insert'.
  Possible C/C++ prototypes are:
    insert(std::vector< float > *,std::vector< float
>::iterator,std::vector< float >::value_type const &)
    insert(std::vector< float > *,std::vector< float
>::iterator,std::vector< float >::size_type,std::vector< float
>::value_type const &)

Obviously this makes STL vectors rather hard for us to use in practice!

I ran into the problem with Fedora 10's package of SWIG 1.3.35 (Fedora
9's build of 1.3.33 works just fine) but confirmed that it also fails
for me with 1.3.35 built from your upstream sources. (But ideally a
backport of any fix to 1.3.35 would be useful, so that Fedora can patch
their package without having to upgrade to an SVN snapshot.)

(Continue reading)

Ben Webb | 4 Dec 20:17
Favicon

Re: Bug in SWIG 1.3.35 with std::vector type system?

Ben Webb wrote:
> I have encountered a problem with SWIG 1.3.35 and later with a fairly
> simple usage of std::vector.

To summarize for the list: non-const iterators were removed from SWIG
1.3.35 (SVN r10322) to quell some compiler warnings. Since insert()
requires a non-const iterator, and begin() now can only return a const
one, the code fails. Backing out the patch fixes the problem for me.
(Presumably the original warnings will also return, but it seems that
warnings are better than non-functional code to me.)

Another possible solution is to remove only the const iterators,
providing only non-const iterators. That also works for me and
presumably would also quell the compiler warnings. It would require the
SWIG type system to understand that non-const objects can be cast to
const though - I'm hopeful that is already the case.

Bug report at
http://sourceforge.net/tracker/index.php?func=detail&aid=2380788&group_id=1645&atid=101645

	Ben
--

-- 
ben <at> salilab.org                      http://salilab.org/~ben/
"It is a capital mistake to theorize before one has data."
	- Sir Arthur Conan Doyle

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
(Continue reading)


Gmane