microsoft / microsoft/SizeBench
"Wasteful virtuals" "virtuals with no overrides" has false positives with multiple levels of inheritance
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 175
- Forks
- 20
- PR merge metrics
- No merged PRs in 30d
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the "wasteful virtuals" heuristic, especially the "virtuals with no overrides" list, using the A/B/C inheritance example in the issue. Reproduce the false positive and verify that A::DoStuff is no longer reported when an override exists through an intermediate derived class.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, csharp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100