Modify

Ticket #3876 (closed Bugs: fixed)

Opened 4 years ago

Last modified 4 years ago

%T format specifier with local_time_facet crashes with MSVC 9

Reported by: Claudio Bley Owned by: az_sw_dude
Milestone: Boost 1.42.0 Component: date_time
Version: Boost 1.41.0 Severity: Problem
Keywords: Cc:

Description

The following program crashes with MSVC9 when trying to write the local_date_time to the stringstream:

#include <boost/date_time/local_time/local_time.hpp> 
#include <iostream>
#include <string>
#include <sstream>

int
main()
{
    using namespace boost::posix_time;
    using namespace boost::local_time;

    time_zone_ptr utc;
    local_date_time now(microsec_clock::universal_time(), utc);

    local_time_facet* output_facet = new local_time_facet();
    local_time_input_facet* input_facet = new local_time_input_facet();

    std::stringstream ss;
    ss.imbue(std::locale(std::locale::classic(), output_facet));
    ss.imbue(std::locale(ss.getloc(), input_facet)); 

    // http://www.boost.org/doc/libs/1_41_0/doc/html/date_time/date_time_io.html#date_time.format_flags
    // %T !  The time in 24-hour notation (%H:%M:%S)
    output_facet->format("%T");

    ss << now; // crash in _Strftime_l
}

With MinGW 4.4.0 it just ignores the %T format specifier. What's the deal with %T?

Attachments

Change History

comment:1 Changed 4 years ago by andysem

This placeholder is not standard, but Boost.DateTime? doesn't handle it itself. This should either be mentioned in docs or fixed in the code.

comment:2 Changed 4 years ago by andysem

(In [62450]) Refs #3876. Made format flags %T and %R to be processed by the library in order to support them on more platforms. Also marked some flags that are known to have similar problems in the docs.

comment:3 Changed 4 years ago by andysem

  • Status changed from new to closed
  • Resolution set to fixed

(In [62667]) Merged changes from trunk (rev. 62450). Fixes #3876.

comment:4 Changed 4 years ago by andysem

(In [62669]) Merged changes from trunk (rev. 62450). Fixes #3876.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.