Title
char8_t and char16_t in integral promotions
Status
cd6
Section
7.3.7 [conv.prom]
Submitter
Richard Smith

Created on 2021-04-01.00:00:00 last changed 27 months ago

Messages

Date: 2021-08-15.00:00:00

Proposed resolution (August, 2021):

Change 7.3.7 [conv.prom] paragraphs 1 and 2 as follows:

A prvalue of an integer type other than bool, char8_t, char16_t, char32_t, or wchar_t whose integer conversion rank (6.8.6 [conv.rank]) is less than the rank of int can be converted to a prvalue of type int if int can represent all the values of the source type; otherwise, the source prvalue can be converted to a prvalue of type unsigned int.

A prvalue of type char8_t, char16_t, char32_t, or wchar_t (6.8.2 [basic.fundamental]) can be converted to a prvalue of the first of the following types that can represent all the values of its underlying type: int, unsigned int, long int, unsigned long int, long long int, or unsigned long long int. If none of the types in that list can represent all the values of its underlying type, a prvalue of type char8_t, char16_t, char32_t, or wchar_t can be converted to a prvalue of its underlying type.

Date: 2021-08-15.00:00:00

Notes from the August, 2021 teleconference:

char8_t should be handled by the second paragraph by including it in all three lists of types in the two paragraphs.

Date: 2021-10-15.00:00:00

[Accepted as a DR at the October, 2021 meeting.]

According to 7.3.7 [conv.prom] paragraphs 1-2,

A prvalue of an integer type other than bool, char16_t, char32_t, or wchar_t whose integer conversion rank (6.8.6 [conv.rank]) is less than the rank of int can be converted to a prvalue of type int if int can represent all the values of the source type; otherwise, the source prvalue can be converted to a prvalue of type unsigned int.

A prvalue of type char16_t, char32_t, or wchar_t (6.8.2 [basic.fundamental]) can be converted to a prvalue of the first of the following types that can represent all the values of its underlying type: int, unsigned int, long int, unsigned long int, long long int, or unsigned long long int. If none of the types in that list can represent all the values of its underlying type, a prvalue of type char16_t, char32_t, or wchar_t can be converted to a prvalue of its underlying type.

Because of its omission from the list of excluded types (perhaps as an oversight when it was added), char8_t is handled in the first paragraph. However, char16_t falls into the second paragraph, even though it is guaranteed to be convertible to int or unsigned int. This seems inconsistent, so perhaps char8_t should be moved to the second paragraph or char16_t moved to the first?

History
Date User Action Args
2022-08-19 07:54:33adminsetstatus: drwp -> cd6
2022-02-15 00:00:00adminsetstatus: dr -> drwp
2021-11-15 00:00:00adminsetmessages: + msg6566
2021-11-15 00:00:00adminsetmessages: + msg6565
2021-04-01 00:00:00admincreate