Re: [Boost-bugs] [Boost C++ Libraries] #5614: date bug in release (boost 1.46)

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #5614: date bug in release (boost 1.46)
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-03-12 17:13:03


#5614: date bug in release (boost 1.46)
-------------------------------+------------------------
  Reporter: ludviglarsson@… | Owner: az_sw_dude
      Type: Bugs | Status: closed
 Milestone: To Be Determined | Component: date_time
   Version: Boost 1.46.1 | Severity: Problem
Resolution: invalid | Keywords:
-------------------------------+------------------------
Changes (by andysem):

 * status: new => closed
 * resolution: => invalid

Comment:

 Your use of printf is incorrect. year(), month() and day() methods return
 class types which have conversion operators to unsigned short. This
 results in incorrect arguments being passed to printf, which makes the
 output incorrect.

 A good compiler would warn you about such inconsistency, and gcc 4.8
 actually does that:

 {{{
 ymd_test.cpp:14:81: warning: format ‘%i’ expects argument of type ‘int’,
 but argument 2 has type ‘boost::date_time::date<boost::gregorian::date,
 boost::gregorian::gregorian_calendar,
 boost::gregorian::date_duration>::year_type {aka
 boost::gregorian::greg_year}’ [-Wformat=]
   printf("%i-%02i-%02i\n",todaysdate.year(), todaysdate.month(),
 todaysdate.day());
 ^
 ymd_test.cpp:14:81: warning: format ‘%i’ expects argument of type ‘int’,
 but argument 3 has type ‘boost::date_time::date<boost::gregorian::date,
 boost::gregorian::gregorian_calendar,
 boost::gregorian::date_duration>::month_type {aka
 boost::gregorian::greg_month}’ [-Wformat=]
 ymd_test.cpp:14:81: warning: format ‘%i’ expects argument of type ‘int’,
 but argument 4 has type ‘boost::date_time::date<boost::gregorian::date,
 boost::gregorian::gregorian_calendar,
 boost::gregorian::date_duration>::day_type {aka
 boost::gregorian::greg_day}’ [-Wformat=] }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/5614#comment:2>
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:15 UTC