Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Struct with two or more bases will have duplicate member names #592

Open
2A5F opened this issue Feb 8, 2025 · 0 comments
Open

Struct with two or more bases will have duplicate member names #592

2A5F opened this issue Feb 8, 2025 · 0 comments

Comments

@2A5F
Copy link

2A5F commented Feb 8, 2025

#367 partially solves the problem, but pure virtual classes will still be generated duplicate

struct Foo
{
    virtual ~Foo() = default;
};

struct Bar
{
    virtual ~Bar() = default;
};

struct Baz: Foo, Bar
{
};

output:

public unsafe partial struct Foo : Foo.Interface
{
    public void** lpVtbl;
    public void Dispose()
    {
        ((delegate* unmanaged[Thiscall]<Foo*, void>)(lpVtbl[0]))((Foo*)Unsafe.AsPointer(ref this));
    }
    public interface Interface
    {
        void Dispose();
    }
}

public unsafe partial struct Bar : Bar.Interface
{
    public void** lpVtbl;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public void Dispose()
    {
        ((delegate* unmanaged[Thiscall]<Bar*, void>)(lpVtbl[0]))((Bar*)Unsafe.AsPointer(ref this));
    }
    public interface Interface
    {
        void Dispose();
    }
}

public unsafe partial struct Baz : Baz.Interface
{
    public void** lpVtbl;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public void Dispose()
    {
        ((delegate* unmanaged[Thiscall]<Baz*, void>)(lpVtbl[0]))((Baz*)Unsafe.AsPointer(ref this));
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public void Dispose()
    {
        ((delegate* unmanaged[Thiscall]<Baz*, void>)(lpVtbl[0]))((Baz*)Unsafe.AsPointer(ref this));
    }
    public interface Interface : Foo.Interface, Bar.Interface
    {
    }
}

This is wrong. There should be multiple virtual table pointers when multiple inheritance occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant