Boost C++ Libraries: Ticket #358: parse_date asserts on empty string https://svn.boost.org/trac10/ticket/358 <pre class="wiki">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) &gt;&gt;&gt; #include &lt;boost/date_time/posix_time/posix_time.hpp&gt; #include &lt;iostream&gt; using namespace boost::gregorian; int main( int, char** ) { try { date d = from_simple_string( "" ); // never reached std::cout &lt;&lt; to_simple_string( d ) &lt;&lt; std::endl; } catch( std::exception &amp; ) { // no std::exception caught ! } return 0; } &gt;&gt;&gt; The error seems to be in date_time\date_parsing.hpp, line 119 : for(boost::tokenizer&lt;&gt;::iterator beg=tok.begin(); beg!=tok.end(), pos &lt; spec_str.size(); ++beg, ++pos) {... the comparison "beg!=tok.end()" has no effect because the value of the expression is only determined by "pos &lt; 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 "&amp;&amp;" 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@bnpparibas.com </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/358 Trac 1.4.3 az_sw_dude Sat, 12 Mar 2005 20:50:35 GMT status changed https://svn.boost.org/trac10/ticket/358#comment:1 https://svn.boost.org/trac10/ticket/358#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> </ul> <pre class="wiki">Logged In: YES user_id=579686 I've checked a change into the latest CVS which resolves the problem and added a test to the gregorian/testparse_date.cpp for this case. Should be part of the 1.33 release. Thx for the report! Jeff </pre> Ticket