Skip to content

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

@phallot

Description

@phallot

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions