microsoft / microsoft/STL

<locale>: the enum value of std::money_base is not correct

Open
#1,112 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug vNext
Dominant language
C++
Stars
11.1k
Forks
1.7k
Avg merge
4d 15h
Merged PRs (30d)
22

Description

Describe the bug
money_base is defined as follows in C++ standard N3797:

class money_base {
public:
    enum part { none, space, symbol, sign, value };
    struct pattern { char field[4]; };
};

Command-line test case

1. >type repro.cpp
#include <locale>
#include <iostream>

int main()
{
    std::money_base mb;
    std::cout << mb.none << std::endl;
    std::cout << mb.space << std::endl;
    std::cout << mb.symbol<< std::endl;
    std::cout << mb.sign << std::endl;
    std::cout << mb.value << std::endl;
}

2. >cl /EHsc /W4 /WX .\repro.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.27.29009.1 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

repro.cpp
Microsoft (R) Incremental Linker Version 14.27.29009.1
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:repro.exe
repro.obj

3. >.\repro.exe
120
32
36
43
118

Expected behavior

0
1
2
3
4

STL version

Microsoft Visual Studio Community 2019 Preview
Version 16.7.0 Preview 3.0

Additional context

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce with repro.cpp using the shown cl command, then inspect the implementation of std::money_base and the skipped libcxx result at tests/libcxx/expected_results.txt. Done means the enum members print 0, 1, 2, 3, and 4 as expected and the related libcxx test is no longer skipped.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
devtools
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.