Movatterモバイル変換


[0]ホーム

URL:


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

2025-11-07


2698. Using extended integer types withz suffix

Section:5.13.2  [lex.icon]    Status:CD7    Submitter:Mike Miller    Date:2023-02-17    Liaison:WG14, EWG

[Accepted as a DR at the June, 2023 meeting.]

Subclause 5.13.2 [lex.icon] paragraph 4 specifies:

If aninteger-literal cannot be represented by any type in itslist and an extended integer type (6.9.2 [basic.fundamental]) canrepresent its value, it may have that extended integer type. If all ofthe types in the list for theinteger-literal are signed, theextended integer type shall be signed. If all of the types in the listfor theinteger-literal are unsigned, the extended integer typeshall be unsigned. If the list contains both signed and unsignedtypes, the extended integer type may be signed or unsigned. A programis ill-formed if one of its translation units containsaninteger-literal that cannot be represented by any of theallowed types.

This implies that aninteger-literal with azsuffix can be of extended integer type, if the literal is larger thanwhat is representable instd::size_t.

According to the author of the paperP0330R8(Literal Suffix for (signed) size_t) introducing the feature, this isunintentional;z should only yieldstd::size_t andits corresponding signed integer type.

See also the corresponding WG14 paperN2998Literal Suffixes for size_t.

Proposed resolution (reviewed by CWG 2023-03-03, approved by CWG 2023-05-12):

Change in 5.13.2 [lex.icon] paragraph 4 as follows:

IfExcept forinteger-literals containingasize-suffix, if the value of aninteger-literalcannot be represented by any type in its list and an extended integertype (6.9.2 [basic.fundamental]) can represent its value, it may havethat extended integer type. If all of the types in the list fortheinteger-literal are signed, the extended integer typeshall beis signed. If all of the types in thelist for theinteger-literal are unsigned, the extended integertypeshall beis unsigned. If the list containsboth signed and unsigned types, the extended integer type may besigned or unsigned.A program is ill-formed if one of itstranslation units containsIf aninteger-literalthat cannot be represented by anyof the allowed types, the program is ill-formed.[ Note: Aninteger-literal with az orZsuffix is ill-formed if it cannot be represented bystd::size_t. -- end note ]

Additional notes (February, 2023)

Alerted the chair of SG22 (C/C++ Liaison).

Forwarded to EWG at the request of the EWG chair viacplusplus/papers#1467.

EWG 2023-05-11

The "z" suffixes meanstd::size_t (or its correspondingsigned type) only. The proposed resolution is accepted by EWG.




[8]ページ先頭

©2009-2025 Movatter.jp