Regression with -Woverloaded-virtual in unit_test_log_t

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Regression with -Woverloaded-virtual in unit_test_log_t

Ben Wiederhake
Hello,

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 (in contrast to the 'compartibility' typo: see #84
on github).

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 (I upgraded only recently), so I
felt free to put "regression" in the subject.

With regards,
Ben Wiederhake
_______________________________________________
Boost-Testing mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-testing
Reply | Threaded
Open this post in threaded view
|

Re: Regression with -Woverloaded-virtual in unit_test_log_t

Rene Rivera-2
On Wed, Aug 26, 2015 at 2:48 PM, Ben Wiederhake <[hidden email]> wrote:
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 (I upgraded only recently), so I
felt free to put "regression" in the subject.

OK.. But.. You posted to the wrong list. You should be posting to either the Boost developers list, or the Boost users list. And follow the posting guidelines <http://www.boost.org/community/policy.html>.


--
-- Rene Rivera
-- Grafik - Don't Assume Anything
-- Robot Dreams - http://robot-dreams.net
-- rrivera/acm.org (msn) - grafikrobot/aim,yahoo,skype,efnet,gmail

_______________________________________________
Boost-Testing mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-testing