C++ Logo

std-discussion

Advanced search

Re: Relative to the underlying type of unscoped enumerations

From: Thiago Macieira <thiago_at_[hidden]>
Date: Thu, 24 Apr 2025 22:23:32 -0700
On Thursday, 24 April 2025 15:38:56 Pacific Daylight Time Vladimir Grigoriev
via Std-Discussion wrote:
> Is it a bug of the MS VS2022 C++ compiler?

Yes, MSVC has a bug here, see Giuseppe's reply.

However, the standard does not dictate what underlying type should be used if
all enumerators fit into the range of both int and unsigned int. In your case,
it can fit in both, so both int and unsigned would be standards-conforming
results.

The MSVC bug is that it uses int even when some enumerators don't fit into int.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel DCAI Platform & System Engineering

Received on 2025-04-25 05:23:38