Ticket #6871 (closed Bugs: wontfix)

Opened 4 years ago

Last modified 3 years ago

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:


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

comment:1 Changed 4 years ago by viboes

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 Changed 3 years ago by viboes

  • Status changed from new to assigned

comment:3 Changed 3 years ago by viboes

  • Version changed from Boost Development Trunk to Boost 1.47.0
  • Milestone changed from To Be Determined to Boost 1.52.0

comment:4 Changed 3 years ago by viboes

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

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

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

comment:5 Changed 3 years ago by viboes

  • Status changed from closed to reopened
  • Resolution fixed deleted

comment:6 Changed 3 years ago by viboes

  • Status changed from reopened to closed
  • Resolution set to wontfix

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

Last edited 3 years ago by viboes (previous) (diff)

Add a comment

Modify Ticket

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

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

Note: See TracTickets for help on using tickets.