OperationCaller has virtual functions but not a virtual destructor, which leads to compile errors with certain compilers and options.
S
Attachment | Size |
---|---|
0001-rtt-Use-virtual-destructor-for-OperationCaller.patch | 783 bytes |
Orocos Real-Time ToolkitSmarter realtime. Safer threads
|
|
PATCH for lack of virtual destructor
OperationCaller has virtual functions but not a virtual destructor, which leads to compile errors with certain compilers and options.
|
PATCH for lack of virtual destructor
Hi Stephen,
On Tue, Feb 17, 2015 at 7:23 PM, S Roderick <kiwi [dot] net [..] ...> wrote:
> OperationCaller has virtual functions but not a virtual destructor, which
> leads to compile errors with certain compilers and options.
>
The class OperationCaller itself does not have virtual methods and I could
not find any other class in RTT that inherits from OperationCaller. The
virtual destructor would only be required if an instance of a subclass of
OperationCaller was deleted from an OperationCaller pointer. Of course it
does not hurt to have one...
OperationCallerBaseInvoker is an abstract base class of OperationCaller
with only virtual methods and should therefore have a virtual destructor
instead, if instances are ever deleted from an OperationCallerBaseInvoker
pointer. I don't see where this would happen within RTT, but it is more
likely because ServiceRequester::getOperationCaller() returns a
OperationCallerBaseInvoker pointer. Could you please try if adding the
destructor to OperationCallerBaseInvoker instead also fixes your compiler
error? This would automatically cause the implicit OperationCaller
destructor to be virtual, too.
S
>
>
Johannes
PATCH for lack of virtual destructor
On Wed, Feb 18, 2015 at 7:18 PM, Stephen Roderick <snr [..] ...>
wrote:
> You were correct. Moving the destructor to the
> *OperationCallerBaseInvoker* class works.
>
Pushed to master and toolchain-2.8:
https://github.com/orocos-toolchain/rtt/commit/abb8ecee57a5e81e6c99fdd91...
Johannes
On Tue, Feb 17, 2015 at 10:07 PM, Johannes Meyer <johannes [..] ...>
wrote:
> Hi Stephen,
>
>
> On Tue, Feb 17, 2015 at 7:23 PM, S Roderick <kiwi [dot] net [..] ...> wrote:
>
>> OperationCaller has virtual functions but not a virtual destructor, which
>> leads to compile errors with certain compilers and options.
>>
>
> The class OperationCaller itself does not have virtual methods and I could
> not find any other class in RTT that inherits from OperationCaller. The
> virtual destructor would only be required if an instance of a subclass of
> OperationCaller was deleted from an OperationCaller pointer. Of course it
> does not hurt to have one...
>
> OperationCallerBaseInvoker is an abstract base class of OperationCaller
> with only virtual methods and should therefore have a virtual destructor
> instead, if instances are ever deleted from an OperationCallerBaseInvoker
> pointer. I don't see where this would happen within RTT, but it is more
> likely because ServiceRequester::getOperationCaller() returns a
> OperationCallerBaseInvoker pointer. Could you please try if adding the
> destructor to OperationCallerBaseInvoker instead also fixes your compiler
> error? This would automatically cause the implicit OperationCaller
> destructor to be virtual, too.
>
>
> S
>>
>>
> Johannes
>