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

"Wasteful virtuals" "virtuals with no overrides" has false positives with multiple levels of inheritance #14

Open
dmachaj opened this issue Sep 13, 2022 · 0 comments

Comments

@dmachaj
Copy link
Collaborator

dmachaj commented Sep 13, 2022

Describe the bug
I was using the "wasteful virtuals" heuristic to try and optimize a large binary. The "virtuals with no overrides" list specifically is easy gains. However, one of the methods flagged does have overrides and removing the virtual keyword introduced a build break.

On closer inspection the problem seems to be that the virtual method and the override has at least one other derived class in the middle.

The heirarchy is roughly as follows:

class A
{
public:
   virtual void DoStuff() { }
};

class B : public A
{ };

class C : public B
{
public:
    void DoStuff() override { }
};

In this case A::DoStuff is considered a wasteful virtual even though C::DoStuff overrides it. Removing the virtual keyword will introduce a build break.

Expected behavior
This method should not be considered wasteful.

Screenshots
N/A

Environment Details
OS is Windows 11.
SizeBench is latest version from the Store at this time (on a different device so I don't have the exact version handy).

Additional context
N/A

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