microsoft / STL

MSVC's implementation of the C++ Standard Library.
Other
10.22k stars 1.5k forks source link

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

Open MahmoudGSaleh opened 4 years ago

MahmoudGSaleh commented 4 years ago

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

StephanTLavavej commented 4 years ago

I believe that changing the values of these enumerators will break ABI; labeling as vNext.