krabsetw icon indicating copy to clipboard operation
krabsetw copied to clipboard

error: integer value 31 is outside the valid range of values [0, 1] for the enumeration type '_SYSTEM_INFORMATION_CLASS'

Open phallot opened this issue 10 months ago • 0 comments

When compiling with a recent clang (17+ if I am not mistaken), the following error is raised: error: integer value 31 is outside the valid range of values [0, 1] for the enumeration type '_SYSTEM_INFORMATION_CLASS' [-Wenum-constexpr-conversion]

This refers to: constexpr auto SystemPerformanceTraceInformation{ static_cast<SYSTEM_INFORMATION_CLASS>(0x1f) };

And indeed SYSTEM_INFORMATION_CLASS is declared as:

typedef enum _SYSTEM_INFORMATION_CLASS {
} SYSTEM_INFORMATION_CLASS;

I don't understand what this cast is supposed to achieve, but the compiler looks right to me: casting a value to a non-existing enum value is UB in C++.
If 0x1f/31 is some kind of default that needs to be supported, then I guess it should be added as an enum value?

Thanks!

phallot avatar Feb 12 '25 15:02 phallot