Movatterモバイル変換


[0]ホーム

URL:


This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 119a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2025-12-20


1022. Can an enumeration variable have values outside the values of the enumeration?

Section:9.8.1  [dcl.enum]    Status:C++11    Submitter:Jason Merrill    Date:2010-01-22

[Voted into the WP at the March, 2011 meeting.]

N3092 comment US 31

According to 9.8.1 [dcl.enum] paragraph 10,

An expression of arithmetic or enumeration type can be convertedto an enumeration type explicitly. The value is unchanged if itis in the range of enumeration values of the enumeration type;otherwise the resulting enumeration value is unspecified.

(There is similar wording in 7.6.1.9 [expr.static.cast].)Does the phrase “resulting enumeration value” meanthat the result, although unspecified, must lie within the rangeof enumeration values of the enumeration type? Existing practiceseems to allow out-of-range values to be preserved if theunderlying type is large enough to represent the value. Thisfreedom is important both for efficiency (to avoid having to maskvalues while storing and/or fetching) and to prevent optimizersfrom removing code that tests for out-of-range values.

Proposed resolution (November, 2010):

This issue is resolved by the resolution ofissue 1094.




[8]ページ先頭

©2009-2026 Movatter.jp