Thanks to visit codestin.com
Credit goes to github.com

Skip to content

<xlocnum>: We don't match numpunct groups correctly in do_get #1277

@StephanTLavavej

Description

@StephanTLavavej

# STL bug: We don't match numpunct groups correctly in do_get
localization\locale.categories\category.numeric\locale.num.get\facet.num.get.members\get_long.pass.cpp

Reduced test case:

C:\Temp>type meow.cpp
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include <cassert>
#include <cstddef>
#include <ios>
#include <locale>
#include <streambuf>
#include <string>

class my_facet : public std::num_get<char, const char*> {
public:
    explicit my_facet(std::size_t refs = 0) : std::num_get<char, const char*>(refs) {}
};

class my_numpunct : public std::numpunct<char> {
protected:
    virtual char_type do_thousands_sep() const {
        return '_';
    }
    virtual std::string do_grouping() const {
        return "\1\2\3";
    }
};

int main() {
    const my_facet f(1);
    std::ios my_ios(nullptr);
    my_ios.imbue(std::locale{std::locale{}, new my_numpunct});

    long v                     = -1;
    const char str[]           = "+1_";
    std::ios_base::iostate err = std::ios_base::goodbit;
    const char* const iter     = f.get(std::begin(str), std::end(str), my_ios, err, v);
    assert(iter == std::end(str) - 1);
    assert(err == std::ios_base::failbit);
    assert(v == 1);
}
C:\Temp>cl /EHsc /nologo /W4 /MTd meow.cpp && meow
meow.cpp
Assertion failed: v == 1, file meow.cpp, line 42

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixedSomething works now, yay!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions