swig-fortran / swig

This fork of SWIG creates Fortran wrapper code from C++ headers.
http://www.swig.org
Other
44 stars 11 forks source link

Virtual single inheritance fails #184

Open sethrj opened 1 year ago

sethrj commented 1 year ago

As noted in the code for #183 , virtual single inheritance is broken:

class A {
  public:
    virtual int foo() { return 1; }
};
class B : virtual public A {
};

If you create a class(B) :: b and call b%foo(), the proxy code for A%foo will be passed a pointer B*. However, the _swig_A_foo wrapper reinterpret-casts the pointer as A*. This is fine for regular classes where A* and B* have the same address, but not fine for virtual classes where the pointers have to be offset. Not sure what the right approach here is...