geometry2 icon indicating copy to clipboard operation
geometry2 copied to clipboard

Non-virtual destructor in tf2_ros::BufferInterface

Open trainman419 opened this issue 9 years ago • 1 comments

When compiling against tf2_ros with -Wnon-virtual-dtor we get the following warning:

In file included from /opt/ros/indigo/include/tf2_ros/buffer.h:35:0,
                 from 
                ... < snipped private file names > ...
/opt/ros/indigo/include/tf2_ros/buffer_interface.h:47:7: warning: ‘class tf2_ros::BufferInterface’ has virtual functions and accessible non-virtual destructor [-Wnon-virtual-dtor]
 class BufferInterface

trainman419 avatar Jan 18 '16 20:01 trainman419

Stumbled upon this in some research work. I suspect this is only an issue if a virtual class has some data members (https://stackoverflow.com/questions/7403883/derived-class-with-non-virtual-destructor). The warning may be spurious for interfaces with no data members. Probably safe to close this.

Alternatively, adding

virtual ~base() = default;

should do the job, which would have the effect of forcing sub-classes to have a virtual destructor (so apparently a bit safer than ignoring)

wasowski avatar May 14 '19 08:05 wasowski