From 9aea92555ffb54b9451ef28a2327be6703d30bd7 Mon Sep 17 00:00:00 2001 From: Mirion <51433180+mirion-dev@users.noreply.github.com> Date: Wed, 4 Mar 2026 13:37:40 +0800 Subject: [PATCH 1/4] Fix `time_get::do_get` to parse a literal `%` --- stl/inc/xloctime | 8 ++++++++ tests/std/test.lst | 1 + .../tests/GH_006130_time_get_do_get_format/env.lst | 4 ++++ .../GH_006130_time_get_do_get_format/test.cpp | 14 ++++++++++++++ 4 files changed, 27 insertions(+) create mode 100644 tests/std/tests/GH_006130_time_get_do_get_format/env.lst create mode 100644 tests/std/tests/GH_006130_time_get_do_get_format/test.cpp diff --git a/stl/inc/xloctime b/stl/inc/xloctime index 15036ae8d77..2ad449c4799 100644 --- a/stl/inc/xloctime +++ b/stl/inc/xloctime @@ -572,6 +572,14 @@ protected: } break; + case '%': + if (_First == _Last || _Ctype_fac.narrow(*_First) != '%') { + _State |= ios_base::failbit; + } else { + ++_First; + } + break; + default: _State |= ios_base::failbit; // unknown specifier break; diff --git a/tests/std/test.lst b/tests/std/test.lst index 2751839bf3d..35035eb782f 100644 --- a/tests/std/test.lst +++ b/tests/std/test.lst @@ -280,6 +280,7 @@ tests\GH_005768_pow_accuracy tests\GH_005780_non_ascii_locales tests\GH_005800_stable_sort_large_alignment tests\GH_005968_headers_provide_begin_end +tests\GH_006130_time_get_do_get_format tests\LWG2381_num_get_floating_point tests\LWG2510_tag_classes tests\LWG2597_complex_branch_cut diff --git a/tests/std/tests/GH_006130_time_get_do_get_format/env.lst b/tests/std/tests/GH_006130_time_get_do_get_format/env.lst new file mode 100644 index 00000000000..34a48eec90c --- /dev/null +++ b/tests/std/tests/GH_006130_time_get_do_get_format/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_matrix.lst diff --git a/tests/std/tests/GH_006130_time_get_do_get_format/test.cpp b/tests/std/tests/GH_006130_time_get_do_get_format/test.cpp new file mode 100644 index 00000000000..92073181b4f --- /dev/null +++ b/tests/std/tests/GH_006130_time_get_do_get_format/test.cpp @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include +#include +#include + +int main() { + std::tm t{}; + std::stringstream ss{"% "}; + ss >> std::get_time(&t, "%%"); + assert(!ss.fail()); +} From 82db724949994d3e9230ead65a4b038f1e5ea334 Mon Sep 17 00:00:00 2001 From: Mirion <51433180+mirion-dev@users.noreply.github.com> Date: Wed, 4 Mar 2026 13:56:03 +0800 Subject: [PATCH 2/4] Use CRLF instead of LF --- tests/std/tests/GH_006130_time_get_do_get_format/env.lst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/std/tests/GH_006130_time_get_do_get_format/env.lst b/tests/std/tests/GH_006130_time_get_do_get_format/env.lst index 34a48eec90c..19f025bd0e6 100644 --- a/tests/std/tests/GH_006130_time_get_do_get_format/env.lst +++ b/tests/std/tests/GH_006130_time_get_do_get_format/env.lst @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -RUNALL_INCLUDE ..\usual_matrix.lst +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_matrix.lst From 60e5e9e16629ee1985bb371753e0884ef7cd62ad Mon Sep 17 00:00:00 2001 From: Mirion <51433180+mirion-dev@users.noreply.github.com> Date: Wed, 4 Mar 2026 15:55:44 +0800 Subject: [PATCH 3/4] Add eofbit check for GH_006130 --- .../GH_006130_time_get_do_get_format/test.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/std/tests/GH_006130_time_get_do_get_format/test.cpp b/tests/std/tests/GH_006130_time_get_do_get_format/test.cpp index 92073181b4f..6a9dbe13862 100644 --- a/tests/std/tests/GH_006130_time_get_do_get_format/test.cpp +++ b/tests/std/tests/GH_006130_time_get_do_get_format/test.cpp @@ -7,8 +7,16 @@ #include int main() { - std::tm t{}; - std::stringstream ss{"% "}; - ss >> std::get_time(&t, "%%"); - assert(!ss.fail()); + { + std::tm t{}; + std::stringstream ss{"%"}; + ss >> std::get_time(&t, "%%"); + assert(!ss.fail() && ss.eof()); + } + { + std::tm t{}; + std::stringstream ss{"% "}; + ss >> std::get_time(&t, "%%"); + assert(!ss.fail() && ss.tellg() == 1); + } } From f29724275a1309582e621682bacf66b19d3db1e3 Mon Sep 17 00:00:00 2001 From: Mirion <51433180+mirion-dev@users.noreply.github.com> Date: Wed, 4 Mar 2026 23:39:02 +0800 Subject: [PATCH 4/4] Move GH-6130 tests to Dev11-0836436 --- tests/std/test.lst | 1 - .../std/tests/Dev11_0836436_get_time/test.cpp | 19 ++++++++++++++++ .../GH_006130_time_get_do_get_format/env.lst | 4 ---- .../GH_006130_time_get_do_get_format/test.cpp | 22 ------------------- 4 files changed, 19 insertions(+), 27 deletions(-) delete mode 100644 tests/std/tests/GH_006130_time_get_do_get_format/env.lst delete mode 100644 tests/std/tests/GH_006130_time_get_do_get_format/test.cpp diff --git a/tests/std/test.lst b/tests/std/test.lst index 35035eb782f..2751839bf3d 100644 --- a/tests/std/test.lst +++ b/tests/std/test.lst @@ -280,7 +280,6 @@ tests\GH_005768_pow_accuracy tests\GH_005780_non_ascii_locales tests\GH_005800_stable_sort_large_alignment tests\GH_005968_headers_provide_begin_end -tests\GH_006130_time_get_do_get_format tests\LWG2381_num_get_floating_point tests\LWG2510_tag_classes tests\LWG2597_complex_branch_cut diff --git a/tests/std/tests/Dev11_0836436_get_time/test.cpp b/tests/std/tests/Dev11_0836436_get_time/test.cpp index ff7a8be5b97..56666164855 100644 --- a/tests/std/tests/Dev11_0836436_get_time/test.cpp +++ b/tests/std/tests/Dev11_0836436_get_time/test.cpp @@ -112,6 +112,7 @@ void test_gh_2618(); void test_gh_2848(); void test_gh_4820(); void test_gh_4882(); +void test_gh_6130(); int main() { assert(read_hour("12 AM") == 0); @@ -160,6 +161,7 @@ int main() { test_gh_2848(); test_gh_4820(); test_gh_4882(); + test_gh_6130(); } typedef istreambuf_iterator Iter; @@ -961,3 +963,20 @@ void test_gh_4882() { fieldValidation(testData.field, testData.hi, testData.fmt); } } + +void test_gh_6130() { + // GH-6130 : time_get::do_get doesn't parse a literal % + { + tm t{}; + stringstream ss{"%"}; + ss >> get_time(&t, "%%"); + assert(!ss.fail() && ss.eof()); + } + + { + tm t{}; + stringstream ss{"% "}; + ss >> get_time(&t, "%%"); + assert(!ss.fail() && ss.tellg() == 1); + } +} diff --git a/tests/std/tests/GH_006130_time_get_do_get_format/env.lst b/tests/std/tests/GH_006130_time_get_do_get_format/env.lst deleted file mode 100644 index 19f025bd0e6..00000000000 --- a/tests/std/tests/GH_006130_time_get_do_get_format/env.lst +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -RUNALL_INCLUDE ..\usual_matrix.lst diff --git a/tests/std/tests/GH_006130_time_get_do_get_format/test.cpp b/tests/std/tests/GH_006130_time_get_do_get_format/test.cpp deleted file mode 100644 index 6a9dbe13862..00000000000 --- a/tests/std/tests/GH_006130_time_get_do_get_format/test.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -#include -#include -#include -#include - -int main() { - { - std::tm t{}; - std::stringstream ss{"%"}; - ss >> std::get_time(&t, "%%"); - assert(!ss.fail() && ss.eof()); - } - { - std::tm t{}; - std::stringstream ss{"% "}; - ss >> std::get_time(&t, "%%"); - assert(!ss.fail() && ss.tellg() == 1); - } -}