Menu

#1096 Bad handling of same name static and member functions

closed-duplicate
nobody
5
2011-01-24
2010-06-19
Evan Shaw
No

Static class functions and member functions by the same name in the same class generate bad Go code. Consider this example:

example.i:
%module example

%inline %{
class Example {
public:
static void Func(int a);
void Func();
};
%}

In example.go, this is generated:

func (p SwigcptrExample) Func(a ...interface{}) {
argc := len(a)
if argc == 0 {
p.Func__SWIG_1()
return
}
if argc == 1 {
p.Func__SWIG_0(a[0].(int))
return
}
fail:
panic("No match for overloaded function call")
}

It looks like SWIG's treating the functions as if they're overloads of the same function, but that's not right.

Discussion

  • William Fulton

    William Fulton - 2011-01-24
    • assigned_to: ianlancetaylor --> nobody
    • labels: 1415660 --> code generation (general)
    • status: open --> closed-duplicate
     

Log in to post a comment.