Opened 10 years ago

Closed 10 years ago

#6871 closed Bugs (wontfix)

chrono_io.hpp: operator<<(ostream& os, ...) modifies the state of os

Reported by: vkh@… Owned by: viboes
Milestone: Boost 1.52.0 Component: chrono
Version: Boost 1.47.0 Severity: Problem
Keywords: Cc:

Description

The code

std::locale loc = os.getloc(); if (!std::has_facet<Facet>(loc))

os.imbue(std::locale(loc, new Facet));

causes the state of os to be changed. It requires the CLIENT code to do own locale saving, like in {

boost::io::ios_locale_saver loc(std::cout); std::cout << boost::chrono::system_clock::now() << std::endl;

}

Compare this to stream io code in boost/date_time (e.g., gregorian_io.hpp), that begins with a (correct)

boost::io::ios_flags_saver iflags(os);

Please fix chrono to behave similarly.

Discovered with 1.47.0 in chrono/chrono_io.hpp, but also exists on the trunk in chrono/io_v1/chrono_io.hpp.

Change History (6)

comment:1 by viboes, 10 years ago

I'm reworking the chrono io for version v2 which uses ios_base states instead of locale facets. Could you check if the version 2 solves the issue?

comment:2 by viboes, 10 years ago

Status: newassigned

comment:3 by viboes, 10 years ago

Milestone: To Be DeterminedBoost 1.52.0
Version: Boost Development TrunkBoost 1.47.0

comment:4 by viboes, 10 years ago

Resolution: fixed
Status: assignedclosed

The issue is solved moving to version 2. You should define BOOST_CHRONO_VERSION=2.

Merged to release [80424][80430][80471].

comment:5 by viboes, 10 years ago

Resolution: fixed
Status: closedreopened

comment:6 by viboes, 10 years ago

Resolution: wontfix
Status: reopenedclosed

I have no fix for io version 1. You should move to version 2.

Last edited 10 years ago by viboes (previous) (diff)
Note: See TracTickets for help on using tickets.