Skip to content

1.69.0: error_code: Warnings about non-virtual destructor #35

@myrkr

Description

@myrkr

When I compile boost 1.69.0 with the -Wnon-virtual-dtor option enabled gcc 6.3.0 gives the following warning (or error if -Werror is active):

.../boost/_/include/boost/system/error_code.hpp:167:28: error: 'class boost::system::error_category' has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]
 class BOOST_SYMBOL_VISIBLE error_category
                            ^~~~~~~~~~~~~~
.../boost/_/include/boost/system/error_code.hpp:275:28: error: base class 'class boost::system::error_category' has accessible non-virtual destructor [-Werror=non-virtual-dtor]
 class BOOST_SYMBOL_VISIBLE generic_error_category: public error_category
                            ^~~~~~~~~~~~~~~~~~~~~~
.../boost/_/include/boost/system/error_code.hpp:275:28: error: 'class boost::system::detail::generic_error_category' has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]
.../boost/_/include/boost/system/error_code.hpp:295:28: error: base class 'class boost::system::error_category' has accessible non-virtual destructor [-Werror=non-virtual-dtor]
 class BOOST_SYMBOL_VISIBLE system_error_category: public error_category
                            ^~~~~~~~~~~~~~~~~~~~~
.../boost/_/include/boost/system/error_code.hpp:295:28: error: 'class boost::system::detail::system_error_category' has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]
cc1plus: all warnings being treated as errors

I worked around the problem by adding the according pragmas disabling the diagnostic to the whole file.

I don't know if the combination of virtual methods (name in the case of error_category) with non-virtual destructor is problematic here. But if not, it would be nice of this kind of warnings could be disabled for the code as there are other reports out there, see facebook/folly#990 for example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions