Skip to content

<xloctime>: time_get::do_get doesn't parse a literal % #6130

@cpplearner

Description

@cpplearner

Describe the bug

MSVC STL's time_get::do_get doesn't know the %% specifier. It should recognize this specifier and consume a literal %.

Command-line test case

D:\test>type test-time-get-do-get.cpp
#include <cassert>
#include <ctime>
#include <iomanip>
#include <sstream>

int main() {
    std::tm t{};
    std::stringstream ss{"% "};
    ss >> std::get_time(&t, "%%");
    assert(!ss.fail());
}
D:\test>cl /EHsc test-time-get-do-get.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.50.35725 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

test-time-get-do-get.cpp
Microsoft (R) Incremental Linker Version 14.50.35725.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:test-time-get-do-get.exe
test-time-get-do-get.obj
D:\test>test-time-get-do-get.exe
Assertion failed: !ss.fail(), file test-time-get-do-get.cpp, line 10

Expected behavior

Assertion passed.

STL version

117ca96

Additional context

Both #6129 and this issue concern time_get::do_get (and affect the same libcxx test file), but they can be fixed independently.

In fact, IMO this issue is much easier to fix and could be a "good first issue".

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions