|
From: <Dan...@dl...> - 2013-02-20 11:47:18
|
Hello,
We've been using an old swig version (1.3.31) for a long time because never versions exhibit
the following problem of mistaking a pointer argument for a bool when trying to disambiguate the
correct version of an overloaded method.
(The following happens when using compactdefaultargs which is quite important for us our current
wrapper.cpp is ~7.9MB in size, and not using this feature increases its size to 9.1MB)
Using the following C++ class
class Example
{
public:
void CheckMe(bool boolValue = true)
{
printf("CheckMe(bool boolValue = %u) called.\n", (unsigned)boolValue);
}
void CheckMe(Example &refValue)
{
printf("CheckMe(Example &refValue = %p) called.\n", &refValue);
}
private:
};
And the following Python code:
import ExampleCompactDefaultArgs
cda = ExampleCompactDefaultArgs.Example()
print("Calling with reference argument (using compactdefaultargs):")
cda.CheckMe(cda)
the CheckMe-method with a bool argument gets called when using swig versions > 1.3.31.
(I do think this happens because 1.3.32 changed the SWIG_ValAs_bool() check to use PY_IsTrue() instead of the stricter check of 1.3.31.
The attached tiny repo-case shows the problem.
In my opinion, this is worth fixing as the behaviour is clearly wrong. Also, is it guaranteed that *not* using compactdefaultargs actually fixes the problem and isn't just a happy coincidence of say – method declaration order?
Best regards
Daniel Vollmer
--------------------------
Deutsches Zentrum für Luft- und Raumfahrt e.V. (DLR)
German Aerospace Center
Institute of Aerodynamics and Flow Technology | Lilienthalplatz 7 | 38108 Braunschweig | Germany
|