|
Boost : |
From: Alexander Grund (alexander.grund_at_[hidden])
Date: 2019-10-16 07:00:47
Am 15.10.19 um 22:45 schrieb Emil Dotchevski via Boost:
> The warning is not correct, and making the destructor virtual is wrong,
> because by design it is a bug to delete the base pointer type. I just
> disabled the warning for MSVC.
The warning is "Virtual class has non-virtual destructor so deleting it
through a base class will lead to bugs", which is correct, isn't it?
As mentioned: Neither the compiler nor a reviewer can confirm that a
delete only ever happens through the most derived pointer because while
error_info_container has a protected destructor (and hence cannot be
deleted through a pointer to that class from outside), the
error_info_container_impl has a public destructor and deletes itself
through a this pointer. So if at any point in time someone derives from
that class (which the missing final allows and there is no comment
advising against that) you will have a bug.
Don't get me wrong: I agree that it is not a bug here and everything is
working as intended *currently*. I'm just saying that the warning is
valid, and the Clang/GCC(?) warning is even more helpful in suggesting
to make this class error_info_container_impl which it should be
according to the design.
While writing this: It seems MSVC already warns for the base class -.-
Again this is a valid warning, but can be ignored for this specific
class because the dtor is protected. I'm not a friend of globally
disabling a warning (for the whole file) without an explanation. I'd
expected it around error_info_container with a comment like `//Never
deleted through base class pointer` as a note to future devs.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk