Skip to content

CWG2689 [basic.fundamental] Clarifying that std::nullptr_t is a fundamental type even though it is defined in header cstddef by changing the non-normative note to a clause #193

Closed
cplusplus/draft
#6906
@ranaanoop

Description

@ranaanoop

Full name of submitter (unless configured in github; will be published with the issue): Anoop Rana

Reference (section label): [basic.fundamental]

Link to reflector thread (if any):

Issue description:

Currently basic.fundamental#14 says:

A value of type std​::​nullptr_­t is a null pointer constant. Such values participate in the pointer and the pointer-to-member conversions ([conv.ptr], [conv.mem]). sizeof(std​::​nullptr_­t) shall be equal to sizeof(void*).

(emphasis mine)

Note the emphasis on the term "value". My point is that the above clause seems to be mainly talking about "value" instead of "type" while it should be mainly talking about the "type" std::nullptr_t which is defined in cstddef.syn inside namespace std.

This matters because basic.fundamental#15 says:

The types described in this subclause are called fundamental types.Note: Even if the implementation defines two or more fundamental types to have the same value representation, they are nevertheless different types. — end note ]

(emphasis mine)

Again note that the above clause talks about "types described" instead of "types of values described" in this subclause. Though this doesn't seem to be a big problem as one can assume that "types described" is the same as "types of value described", I suggest that we should instead move atleast part of the non-normative note to basic.fundamental#14.

Suggested resolution:

Change basic.fundamental#14 to as highlighted(in bold) below:

std​::​nullptr_­t is a distinct type that is neither a pointer type nor a pointer-to-member type. A value of type std​::​nullptr_­t is a null pointer constant. Such values participate in the pointer and the pointer-to-member conversions ([conv.ptr], [conv.mem]). sizeof(std​::​nullptr_­t) shall be equal to sizeof(void*)..

As we can see the note from lex.nullptr is taken and is added into basic.fundamental#14.


Moroever if needed a separate note can be added into basic.fundamental#15 saying as highlighted(in bold) below:

The types described in this subclause are called fundamental types.
Note: Even if the implementation defines two or more fundamental types to have the same value representation, they are nevertheless different types. — end note ]
[Note: Even though std::nullptr_t is declared in cstddef, it is still considered a fundamental type --end note]

Note that the above added note is the second change that this issue suggests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions