Subject: [Boost-bugs] [Boost C++ Libraries] #11582: Regression with -Woverloaded-virtual in unit_test_log_t
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-08-26 20:52:45
#11582: Regression with -Woverloaded-virtual in unit_test_log_t
-----------------------------------------------+---------------------
Reporter: Ben Wiederhake <Ben.Wiederhake@â¦> | Owner: rogeeff
Type: Bugs | Status: new
Milestone: To Be Determined | Component: test
Version: Boost Development Trunk | Severity: Problem
Keywords: |
-----------------------------------------------+---------------------
While trying to compile my code with "-Woverloaded-virtual -Werror", I
found a shortcoming, possibly even a bug.
In 1.59.0 (and, as far as I can see in git, all following versions),
there are the following declarations/definitions:
{{{
class test_observer /* boost/test/tree/observer.hpp:40 */
virtual void test_unit_skipped( test_unit const& tu, const_string)
{ test_unit_skipped( tu ); }
virtual void test_unit_skipped( test_unit const& )
{} ///< backward compartibility
class unit_test_log_t /* boost/test/unit_test_log.hpp:97 */
virtual void test_unit_skipped( test_unit const&, const_string );
/* Actually uses the message in the implementation */
/* Does not override Test_unit_skipped( test_unit const& ) */
}}}
The problem with this code is that code like the following simply will
not work:
{{{
unit_test_log_t& foobar;
test_unit const& tu;
foobar.test_unit_skipped( tu ); // <-- Error!
}}}
g++ would say "candidate expects 2 arguments, 1 provided". clang++ is a
tad more helpful, and would say: "too few arguments to function call,
expected 2, have 1; did you mean 'test_observer::test_unit_skipped'?"
In case you're unfamiliar with that behaviour, see this specific answer:
http://stackoverflow.com/a/6035884/3070326
(Error messages are from a different compilation, but should be the same.)
I hope I have now established that -Woverloaded-virtual "has a point".
I don't fully understand why unit_test_log_t doesn't override the
other signature, too; but it should be easily possible to override
it with something like:
{{{
test_unit_skipped( tu, "<No message>" );
}}}
However, I do not yet fully understand the context of unit_test_log_t,
so maybe such a call cannot occur. That's why I'm unable to make a
patch from that idea.
At the very least, this issue is annoying for people who use Boost.Test
and try to compile with -Woverloaded-virtual.
Note that Boost.Test 1.58.0 did *not* exhibit this issue, so I felt free
to put "regression" in the subject and 'severity'.
(PS: Thanks to Rene Rivera for redirecting me away from the mailing list,
and Raffi Enficiaud for redirecting me to this trac.)
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/11582> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:18 UTC