Title
Redundant specification of value category of literals
Status
c++23
Section
5.13 [lex.literal]
Submitter
Andrey Erokhin

Created on 2022-11-07.00:00:00 last changed 16 months ago

Messages

Date: 2022-11-12.03:50:17

Proposed resolution (approved by CWG 2022-11-10):

  1. Change in 5.13.1 [lex.literal.kinds] paragraph 1 as follows:

    There are several kinds of literals. [ Footnote: ... ]
    literal:
        integer-literal
        character-literal
        floating-point-literal
        string-literal
        boolean-literal
        pointer-literal
        user-defined-literal
    
    [ Note: When appearing as an expression, a literal has a type and a value category (7.5.2 [expr.prim.literal]). -- end note ]
  2. Change in 5.13.2 [lex.icon] paragraph 3 as follows:

    The type of an integer-literal is the first type in the list in Table 9 corresponding to its optional integer-suffix in which its value can be represented. An integer-literal is a prvalue.
  3. Change in 5.13.7 [lex.bool] paragraph 1 as follows:

    The Boolean literals are the keywords false and true. Such literals are prvalues and have type bool.
  4. Change in 5.13.8 [lex.nullptr] paragraph 1 as follows:

    The pointer literal is the keyword nullptr. It is a prvalue of has type std::nullptr_t.
Date: 2022-11-15.00:00:00

[Accepted as a DR at the November, 2022 meeting.]

Subclause 7.5.2 [expr.prim.literal] paragraph 1 specifies:

... A string-literal is an lvalue designating a corresponding string literal object (5.13.5 [lex.string]), a user-defined-literal has the same value category as the corresponding operator call expression described in 5.13.9 [lex.ext], and any other literal is a prvalue.

Yet, there is redundant specification in 5.13.2 [lex.icon] paragraph 3:

The type of an integer-literal is the first type in the list in Table 9 corresponding to its optional integer-suffix in which its value can be represented. An integer-literal is a prvalue.

And in 5.13.7 [lex.bool] paragraph 1:

The Boolean literals are the keywords false and true. Such literals are prvalues and have type bool.

And in 5.13.8 [lex.nullptr] paragraph 1:

The pointer literal is the keyword nullptr. It is a prvalue of type std::nullptr_t.
History
Date User Action Args
2023-07-16 13:00:43adminsetstatus: open -> c++23
2023-07-16 13:00:43adminsetstatus: drwp -> open
2023-02-18 18:43:04adminsetstatus: dr -> drwp
2022-11-25 05:14:04adminsetstatus: ready -> dr
2022-11-12 03:50:17adminsetmessages: + msg7004
2022-11-09 21:43:53adminsetstatus: open -> ready
2022-11-09 21:43:53adminsetstatus: open -> open
2022-11-09 21:43:53adminsetstatus: open -> open
2022-11-09 21:43:53adminsetstatus: open -> open
2022-11-07 12:52:03adminsetstatus: ready -> open
2022-11-07 12:52:03adminsetstatus: ready -> ready
2022-11-07 12:52:03adminsetstatus: ready -> ready
2022-11-07 00:00:00admincreate