Boost logo

Boost :

From: Alexander Konovalenko (a-konovalenko_at_[hidden])
Date: 2004-11-23 12:54:32


>On Tue, 23 Nov 2004 19:01:45 +0300 (MSK), Alexander Konovalenko wrote
>> I expected it to throw some descendant of a standard exception
>> instead. Is it indeed the accepted policy in the Date_time library
>
>Yes, that is what should happen. Sometimes you can get a lexical_cast
>exception, but that is also std::exception derived. Not sure you can tell
>that this isn't the cause of the abort from this program, however, since you
>don't handle the exception and the compiler knows that. I'd add a try/catch
>and see what happens.

I forgot to mention explicitly that I had checked that no std::exception-derived exception was thrown. (This can also be deduced from the error message, since an uncaught exception in main() can't cause any assertion inside Boost to fail.) To make sure, you can compile and run the attached file.

>I'm actually mildly suprised that that particular format isn't accepted. My
>guess is that if you add seconds onto the duration it will work.

Neither (see the attached file). (Note that the formats "2004-Nov-23 15" and "2004-Nov-23 15:00" are accepted by my version of the library and mean the same thing.)

>In general,
>date-time will accept any 'delimiter' char between various elements of a
>date including spaces.

>From a quick look at the source code, it doesn't seem so, but I haven't had time to examine that well. It might be the case when the date is there alone (didn't check that), but it doesn't work badly, as you can see, when using time_from_string() to parse both date and time.

To support my claims, attached is the updated version of the test program. It still fails in my setting with the same error message about a _failed assertion_:

date_format_bug_demo2: /usr/include/boost/token_iterator.hpp:59: const Type& boost::token_iterator<TokenizerFunc, Iterator, Type>::dereference() const [with TokenizerFunc = boost::char_delimiters_separator<char, std::char_traits<char> >, Iterator = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Type = std::basic_string<char, std::char_traits<char>, std::allocator<char> >]: Assertion `valid_' failed.
Aborted

So I believe this is a bug in the date-time library.

>BTW, there is a major rewrite of I/O that will be in 1.33 that will allow
>you to define format strings for parsing and output via a new facet.

Is it in the CVS already? What's your estimate of the release date?

 -- Alexander




Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk