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

Compiler warning when deleting a BME280I2C object #136

Open
nurazur opened this issue Jul 5, 2023 · 0 comments
Open

Compiler warning when deleting a BME280I2C object #136

nurazur opened this issue Jul 5, 2023 · 0 comments

Comments

@nurazur
Copy link

nurazur commented Jul 5, 2023

Expected behavior

no compiler warning when deleting a BME280I2C object.

Actual behavior

warning: deleting object of polymorphic class type 'BME280I2C' which has non-virtual destructor might cause undefined behavior [-Wdelete-non-virtual-dtor]
delete BME280;
^~~~~~

Steps to reproduce the behavior

BME280I2C *BME280;
BME280 = new BME280I2C();
// ...
delete BME280;

Solution to avoid compiler warning

add virtual destructor in BME280I2C.h:
virtual ~BME280I2C(){}

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