Skip to content

Compiler warning when deleting a BME280I2C object #136

@nurazur

Description

@nurazur

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(){}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions