'Value of enum class gets scrambled when stored to std::pair

I have defined custom enum class as follows

enum class BaseType:std::uint8_t{
    ENUM = 0x00,
    SINT8 = 0x01,
    UINT8 = 0x02,
    SINT16 = 0x83,
    UINT16 = 0x84,
    SINT32 = 0x85,
    UINT32 = 0x86,
    STRING = 0x07,
    FLOAT32 = 0x88,
    FLOAT64 = 0x89,
    UINT8Z = 0x0A,
    UINT16Z = 0x8B,
    UINT32Z = 0x8C,
    BYTE = 0x0D,
    SINT64 = 0x8E,
    UINT64 = 0x8F,
    UINT64Z = 0x90
};

when I try to use it inside std::pair its value changes

void Message::addData(std::uint8_t fieldID, const std::any& data, BaseType type){
    int a = 10;
    std::pair<int, BaseType> pair (a, type);
    //_data.insert_or_assign(fieldID, pair);
}

Debuger view

the value of type is BaseType::UINT16 (132) but it is scrambled to BaseType::STRING | BaseType::SINT16 | unknown: -256 (-124) when stored into std::pair

does someone know what I am doing wrong? I am using gcc 11.1.0



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source