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

Missing virtual destructors #260

Open
matthewT53 opened this issue Nov 28, 2021 · 3 comments
Open

Missing virtual destructors #260

matthewT53 opened this issue Nov 28, 2021 · 3 comments
Labels

Comments

@matthewT53
Copy link

matthewT53 commented Nov 28, 2021

Hello, when building FakeIt 2.0.9 from conan-center I get the following warnings as errors:

/home/someUser/.conan/data/fakeit/2.0.9/_/_/package/2c17f3a304303e51860708bc68822afdefc5985f/include/fakeit.hpp:740:12: error: ‘s
truct fakeit::VerificationEventHandler’ has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]     740 |     struct VerificationEventHandler {                                                                                    
      |            ^~~~~~~~~~~~~~~~~~~~~~~~ 
/home/someUser/.conan/data/fakeit/2.0.9/_/_/package/2c17f3a304303e51860708bc68822afdefc5985f/include/fakeit.hpp:746:12: error: ba
se class ‘struct fakeit::VerificationEventHandler’ has accessible non-virtual destructor [-Werror=non-virtual-dtor]                746 |     struct EventHandler : public VerificationEventHandler {                                                       
      |            ^~~~~~~~~~~~                                                                                                  

I am building my C++ project with meson with warning level = 3 and Werror set to true.

There are non-virtual-dtor errors in more classes.
I've tried to fix the issue by adding virtual destructors into the affected classes however when I try to run the unit tests I get free(); Invalid pointer.

[--------------]
[ RUN          ] VirtualOffsetSelectorTest::verifyAllIndexes
[       PASSED ] VirtualOffsetSelectorTest::verifyAllIndexes
[--------------]

[--------------]
[ RUN          ] BasicVerification::verificationProgressShouldBeConvertibleToBool
free(): invalid pointer
@malcolmdavey
Copy link
Contributor

Just tried what I think you are doing on windows Visual Studio 2019, but haven't got that problem.

Could you show your changed classes?
Also are you only getting this when building the tests?

Will take more time to get gcc going to try it out.

@FranckRJ
Copy link
Collaborator

FranckRJ commented Nov 9, 2022

I'm not sure fakeit is really designed to be build with a high error level (there a some hacks inside the library). I don't know meson but I'm pretty sure you should be able to disable / reduce warning level for system headers (everything included with <>, it's a feature in GCC/Clang and MSVC).

But if we can reduce the number of warnings (or locally silence the ones we're sure are "false-positive") it's always better. So I guess we shouldn't ignore these too much.

@malcolmdavey
Copy link
Contributor

malcolmdavey commented Nov 9, 2022

I've tried to fix the issue by adding virtual destructors into the affected classes however when I try to run the unit tests I get free(); Invalid pointer.

I'm wondering if this case is fixed by some of the recent dtor changes (I think will be in 2.3.1) e.g. #289

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

No branches or pull requests

3 participants