-
Notifications
You must be signed in to change notification settings - Fork 46
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
exception.hpp: warning C4265 given by Visual Studio #23
Comments
Sorry I had missed this. See boostorg/throw_exception@43a57d5 |
I know this is closed, but the warning / error doesn't appear to be a false report. Instead of disabling the warning, shouldn't the destructor have been made virtual? |
It is incorrect for this destructor to be virtual. The destructor is never called via a pointer to the base type. |
As a general rule classes with virtual methods ought to have a virtual destructor which is the reason for the warning. It certainly wouldn't hurt anything for the the destructor to be virtual. There is nothing incorrect about a virtual, protected method. It seems like it was more of a preference for someone to disable the warning. |
It is a deliberate design decision. Marking a function virtual indicates dynamic polymorphism. In this design, calling the destructor polymorphically would be a logic error. In C++, this is communicated by declaring the destructor protected and non-virtual. |
This has been reported before (https://svn.boost.org/trac10/ticket/13227), but I am not sure that tracker is still active. The problem is still relevant with boost 1.65.1 and 1.70.
Quoting:
The above link has reproduction steps, in particular, https://github.com/ivsgroup/boost_warnings_minimal_demo
The text was updated successfully, but these errors were encountered: