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