From dcd10a2be55c2cce57a544d790bf8d3a0b301056 Mon Sep 17 00:00:00 2001 From: grcm10 Date: Sat, 24 Feb 2024 18:04:06 +0900 Subject: [PATCH 1/3] Fix the incorrect width that occurred when formatting a floating number in the locale specific form --- stl/inc/format | 1 + .../P0645R10_text_formatting_formatting/test.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/stl/inc/format b/stl/inc/format index 84c71181cf3..f22b4447fdd 100644 --- a/stl/inc/format +++ b/stl/inc/format @@ -3111,6 +3111,7 @@ _NODISCARD _OutputIt _Fmt_write( if (_Specs._Localized) { _Groups = _STD use_facet>(_Locale._Get()).grouping(); _Separators = _Count_separators(static_cast(_Integral_end - _Buffer_start), _Groups); + _Width += _Separators; } } diff --git a/tests/std/tests/P0645R10_text_formatting_formatting/test.cpp b/tests/std/tests/P0645R10_text_formatting_formatting/test.cpp index f516e4735e7..9603aacdca8 100644 --- a/tests/std/tests/P0645R10_text_formatting_formatting/test.cpp +++ b/tests/std/tests/P0645R10_text_formatting_formatting/test.cpp @@ -1506,6 +1506,12 @@ constexpr bool test_format_string() { return true; } +template +void test_gh_4316() { + assert(format(locale{"en-US"}, STR("{:@>8L}"), 12345) == STR("@@12,345")); + assert(format(locale{"en-US"}, STR("{:@>8L}"), 12345.0) == STR("@@12,345")); +} + // Also test GH-4319: incorrect output for some floating-point values template void test_gh_4319() { @@ -1589,6 +1595,11 @@ void test() { test_localized_char(); test_localized_char(); +#if !defined(_DLL) || _ITERATOR_DEBUG_LEVEL == DEFAULT_IDL_SETTING + test_gh_4316(); + test_gh_4316(); +#endif // !defined(_DLL) || _ITERATOR_DEBUG_LEVEL == DEFAULT_IDL_SETTING + test_gh_4319(); test_gh_4319(); } From 9db14db41d5bd807d1ca1ada9840bcbcfe11b6d8 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Sat, 24 Feb 2024 15:25:05 -0800 Subject: [PATCH 2/3] Update libcxx skips. --- tests/libcxx/expected_results.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/libcxx/expected_results.txt b/tests/libcxx/expected_results.txt index 8976ee564fc..9b10a3ef396 100644 --- a/tests/libcxx/expected_results.txt +++ b/tests/libcxx/expected_results.txt @@ -568,10 +568,6 @@ std/input.output/string.streams/stringbuf/stringbuf.members/view.pass.cpp FAIL std/input.output/syncstream/syncbuf/syncstream.syncbuf.cons/dtor.pass.cpp FAIL std/input.output/syncstream/syncbuf/syncstream.syncbuf.members/emit.pass.cpp FAIL -# GH-4316: : The width of output is miscalculated when formatting a floating-point number in the locale-specific form -std/input.output/iostream.format/output.streams/ostream.formatted/ostream.formatted.print/locale-specific_form.pass.cpp FAIL -std/utilities/format/format.functions/locale-specific_form.pass.cpp FAIL - # *** VCRUNTIME BUGS *** # DevCom-10373274 VSO-1824997 "vcruntime nothrow array operator new falls back on the wrong function" From ad6396b13c0e353d7f9193413dbdd80fdefdf8ba Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Sat, 24 Feb 2024 15:28:59 -0800 Subject: [PATCH 3/3] Cite bug title. --- tests/std/tests/P0645R10_text_formatting_formatting/test.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/std/tests/P0645R10_text_formatting_formatting/test.cpp b/tests/std/tests/P0645R10_text_formatting_formatting/test.cpp index 9603aacdca8..c6295a44c3e 100644 --- a/tests/std/tests/P0645R10_text_formatting_formatting/test.cpp +++ b/tests/std/tests/P0645R10_text_formatting_formatting/test.cpp @@ -1506,6 +1506,8 @@ constexpr bool test_format_string() { return true; } +// Also test GH-4316 : The width of output is miscalculated +// when formatting a floating-point number in the locale-specific form template void test_gh_4316() { assert(format(locale{"en-US"}, STR("{:@>8L}"), 12345) == STR("@@12,345"));