Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

D2372R1: Fixing locale handling in chrono formatters #1891

Closed
vitaut opened this issue May 1, 2021 · 5 comments
Closed

D2372R1: Fixing locale handling in chrono formatters #1891

vitaut opened this issue May 1, 2021 · 5 comments
Labels
chrono C++20 chrono format C++20/23 format LEWG issue needed A design defect that should be submitted to LEWG as a new issue

Comments

@vitaut
Copy link
Contributor

vitaut commented May 1, 2021

Describe the bug

Chrono formatting depends on locale by default and doesn't provide control over locale which is inconsistent with all the other standard formatters (https://cplusplus.github.io/LWG/issue3547).

Command-line test case

C:\test>type test.cc
#include <chrono>
#include <format>
#include <iostream>

int main() {
  std::locale::global(std::locale("ru_RU"));
  std::cout << std::format("{}\n", 0.042);
  std::cout << std::format("{:%S}\n", std::chrono::milliseconds(42));
}

C:\test>cl test.cc /std:c++latest /I STL/stl/inc STL/stl/src/format.cpp /EHsc
Microsoft (R) C/C++ Optimizing Compiler Version 19.29.29917 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

/std:c++latest is provided as a preview of language features from the latest C++
working draft, and we're eager to hear about bugs and suggestions for improvements.
However, note that these features are provided as-is without support, and subject
to changes or removal as the working draft evolves. See
https://go.microsoft.com/fwlink/?linkid=2045807 for details.

cl : Command line warning D9026 : options apply to entire command line
test.cc
format.cpp
Generating Code...
Microsoft (R) Incremental Linker Version 14.29.29917.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:test.exe
test.obj
format.obj

C:\test>test
0.042
00,042

Expected behavior

Expected the output to be

0.042
00.042

i.e. not depend on the locale.

STL version

f675d68

@StephanTLavavej StephanTLavavej linked a pull request May 2, 2021 that will close this issue
@StephanTLavavej StephanTLavavej added bug Something isn't working chrono C++20 chrono format C++20/23 format labels May 2, 2021
@barcharcraz barcharcraz changed the title <chrono>: inconsistent locale handling in chrono formatters D2372R1: Fixing locale handling in chrono formatters May 5, 2021
@barcharcraz barcharcraz added cxx23 C++23 feature LEWG issue needed A design defect that should be submitted to LEWG as a new issue and removed bug Something isn't working labels May 5, 2021
@barcharcraz
Copy link
Member

While this is a problem, it's a problem in the standard, not a bug in our implementation.

I've renamed the issue to reflect what I think is the latest paper number addressing this. (It's somewhat unlikely the LWG issue will be adopted)

@StephanTLavavej StephanTLavavej removed the cxx23 C++23 feature label May 7, 2021
@StephanTLavavej
Copy link
Member

@barcharcraz Note, I have removed the cxx23 label as that denotes accepted C++23 papers. If and when this paper is voted in, we should create a cxx23-labeled issue tracking the final revision. This label affects the Status Chart (see screenshot), and so does the time of issue creation - so when this paper is voted in, we should create a fresh issue to track that.

cxx23

No objections to keeping this issue with the "LEWG issue needed" etc. labels.

@ghost
Copy link

ghost commented May 16, 2022

Excuse me, does #2273 (P2372R3) solved this issue?

@CaseyCarter
Copy link
Member

Excuse me, does #2273 (P2372R3) solved this issue?

LWG-3547 certainly seems to think it does. @barcharcraz, is there anything else to do here, or shall we consider this issue fixed?

@StephanTLavavej
Copy link
Member

+1 for closing this as fixed (and superseded by issue #2237, which amusingly is a digit transposition of the PR #2273).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chrono C++20 chrono format C++20/23 format LEWG issue needed A design defect that should be submitted to LEWG as a new issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants