0
myNameSpace::myEnumType LookupEnumValueFromString(const std::string& theString)
{
    myEnumType ReturnVal = myNameSpace::myEnumType::eUNKNOWN;

Parasoft reports “Implicit conversion of integer type from wider to narrower type shall not be used” on the assignment to myEnumType.

Where

namespace myNameSpace
{
    
    enum class myEnumType : uint32_t
    {
        ....  // other values
        eUNKNOWN = 0xFFFFFFFF
    }

and

typedef unsigned int       uint32_t;

If I redefine eUNKNOWN to be 0x7FFFFFFF, the report goes away. But the enum type is unsigned, so why does this happen? I am sure that I am overlooking something very obvious, but what?

halfer
  • 19,824
  • 17
  • 99
  • 186
Mawg says reinstate Monica
  • 38,334
  • 103
  • 306
  • 551

0 Answers0