Discovering and handling missing override keyword in project conversion

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Discovering and handling missing override keyword in project conversion

Boost - Dev mailing list
I'm in the middle of converting a large project from C++03 to C++14, and of
course crossing the C++11 gap, I want identify all of the places where the
override keyword should be used but is not, and add it.

When I turned on -Wsuggest-override in gcc-7.2 I got a fair number of
warnings from boost code, for example:

...boost/program_options/value_semantic.hpp:304:14: error: ‘bool
boost::program_options::typed_value<T, charT>::is_composing() const [with T
= std::basic_string<char>; charT = char]’ can be marked override
[-Werror=suggest-override]
         bool is_composing() const { return m_composing; }
              ^~~~~~~~~~~~
...boost/program_options/value_semantic.hpp:306:18: error: ‘unsigned int
boost::program_options::typed_value<T, charT>::min_tokens() const [with T =
std::basic_string<char>; charT = char]’ can be marked override
[-Werror=suggest-override]
         unsigned min_tokens() const
                  ^~~~~~~~~~
...boost/program_options/value_semantic.hpp:315:18: error: ‘unsigned int
boost::program_options::typed_value<T, charT>::max_tokens() const [with T =
std::basic_string<char>; charT = char]’ can be marked override
[-Werror=suggest-override]
         unsigned max_tokens() const {
                  ^~~~~~~~~~
...boost/program_options/value_semantic.hpp:325:14: error: ‘bool
boost::program_options::typed_value<T, charT>::is_required() const [with T
= std::basic_string<char>; charT = char]’ can be marked override
[-Werror=suggest-override]
         bool is_required() const { return m_required; }
              ^~~~~~~~~~~

(There were others - this is just a small sample)

This is probably not the first time this has been brought up, but there is
no BOOST_OVERRIDE (or BOOST_FINAL, for that matter) definition in
Boost.Config that would allow Boost itself to be compatible with C++03 or
C++11 cleanly relative to this language feature.  I found a number of posts
about this issue elsewhere.  Has this issue been discussed here before?

I could spend some time adding this to Boost.Config and then making boost
compile cleanly with cxxstd=03,11 toolset=gcc-7
cxxflags="-Wsuggest-override", as it would help support a more complete
conversion to the new language level for projects, and it would enable
existing projects to turn on the warning to improve their code, as well as
improve Boost.

Thoughts?

- Jim

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost