|
Boost : |
From: SourceForge.net (noreply_at_[hidden])
Date: 2005-03-02 22:27:17
Bugs item #1155556, was opened at 2005-03-02 19:27
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=107586&aid=1155556&group_id=7586
Category: date_time
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Jeff Garland (az_sw_dude)
Summary: parse_date asserts on empty string
Initial Comment:
the following sample code fails with assert :
(Assertion failed: valid_, file
c:\dev\externallibs\boost_1_32_0\boost\token_iter
ator.hpp, line 57)
>>>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <iostream>
using namespace boost::gregorian;
int main( int, char** )
{
try
{
date d = from_simple_string( "" );
// never reached
std::cout << to_simple_string( d ) << std::endl;
}
catch( std::exception & )
{
// no std::exception caught !
}
return 0;
}
>>>
The error seems to be in date_time\date_parsing.hpp,
line 119 :
for(boost::tokenizer<>::iterator beg=tok.begin();
beg!=tok.end(), pos < spec_str.size(); ++beg, ++pos) {...
the comparison "beg!=tok.end()" has no effect because
the value of the expression is only determined by "pos
< spec_str.size()".
Therefore the string iteration goes beyond the end of
the string and...assert...
The function also fails if the given string is not a
complete date, ie: "2004", "2004-Jan"
I changed the "," to "&&" and it seems to perform
better (though i didn't run the boost regression tests).
I also checked the CVS repository to confirm the bug is
still there.
Have a nice day ! and thanks for this great library, it
is really good to develop with it.
Here is my email : guillaume.souchet_at_[hidden]
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=107586&aid=1155556&group_id=7586
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Boost-bugs mailing list
Boost-bugs_at_[hidden]
https://lists.sourceforge.net/lists/listinfo/boost-bugs
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk