This is a clarification for Bug 3086615 which has been prematurely closed. ( https://sourceforge.net/tracker/?func=detail&aid=3086615&group_id=1645&atid=101645 )
In that report, I forgot to mention one precondition for this issue: The class has to be named according to the stripped prefix. So the following "example.i" triggers the bug:
%module example
%inline %{
class Cool {
public:
int somethingCool_Fast() {
return 42;
}
};
%}
The "example.so" can be built with the following commands:
swig -ruby -c++ example.i
g++ -shared -fPIC -I"`ruby -r rbconfig -e 'puts(Config::CONFIG["archdir"] || "")'`" -o example.so example_wrap.cxx
Then, the following Ruby snippet fails:
require 'example'
c = Example::Cool.new
puts c.somethingCool_Fast() # fails, but shouldn't
However, the following Ruby code works, although it shouldn't:
require 'example'
c = Example::Cool.new
puts c.somethingFast() # outputs "42", but should fail as there is no such method
I confirmed that this issue still exists in the current SWIG 2.0.2 release.
Still present in git master.
This patch seems to fix it, and
make check-ruby-test-suitestill passes:Actually it should really just erase (or not copy in the first place) the first
Len(prefix)characters given we do theStrncmp()and so know the string starts withprefix.Needs the testcase adding to the testsuite too.
Fixed in git master for 4.1.0: