[Boost-bugs] [Boost C++ Libraries] #6513: assignment vs comparison in unit test

Subject: [Boost-bugs] [Boost C++ Libraries] #6513: assignment vs comparison in unit test
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-02-02 12:03:38


#6513: assignment vs comparison in unit test
---------------------------------------------------------------+------------
 Reporter: Ulrich Eckhardt <ulrich.eckhardt@…> | Owner: az_sw_dude
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: date_time
  Version: Boost 1.48.0 | Severity: Problem
 Keywords: |
---------------------------------------------------------------+------------
 In file date_time\test\gregorian\testdate_input_facet.cpp is the following
 line:
 {{{
     check("No extra characters consumed", m = greg_month(Mar) && *sitr ==
 '.');
 }}}
 Compiling with VC8 gives a warning C4800: 'unsigned short' : forcing value
 to bool 'true' or 'false' (performance warning). I believe the problem is
 that m is being assigned to, so that the actual expression being given to
 check() or operator&& is m, which is converted to a boolean. I would also
 split the test into two lines, just for clarity:
 {{{
     check("Correct input", m == greg_month(Mar));
     check("No extra characters consumed", *sitr == '.');
 }}}

 I found this bug in 1.48, but it is still present in the trunk, even
 though in the trunk the tests were converted from the ad-hoc test
 framework to Boost's general test framework. It might apply to other
 versions, too.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/6513>
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:08 UTC