Title
Circular definition of std::size_t
Status
c++11
Section
7.6.2.5 [expr.sizeof]
Submitter
GB

Created on 2010-08-02.00:00:00 last changed 131 months ago

Messages

Date: 2010-11-15.00:00:00

[Voted into the WP at the November, 2010 meeting.]

Date: 2010-09-15.00:00:00

Proposed resolution (September, 2010):

Add the following three paragraphs after 17.2 [support.types] paragraph 4:

The type ptrdiff_t is an implementation-defined signed integer type that can hold the difference of two subscripts in an array object, as described in 7.6.6 [expr.add].

The type size_t is an implementation-defined unsigned integer type that is large enough to contain the size in bytes of any object.

[Note: It is recommended that implementations choose types for ptrdiff_t and size_t whose integer conversion ranks (7.3.15 [conv.bool]) are no greater than that of signed long int unless a larger size is necessary to contain all the possible values. —end note]

Date: 2022-02-18.07:47:23
N3092 comment GB 24

The return type of the sizeof operator is defined as being of type std::size_t, defined in library 17.2 [support.types]. This, in turn, says that size_t is defined in the C standard, which in turn says that size_t is defined as the type of the result of the sizeof operator!

The C definition of sizeof returns an implementation-defined unsigned integer type, recommended not to have “an integer conversion rank greater than signed long int, unless the implementation supports objects large enough to make this necessary.”

History
Date User Action Args
2014-03-03 00:00:00adminsetstatus: fdis -> c++11
2011-04-10 00:00:00adminsetstatus: dr -> fdis
2010-11-29 00:00:00adminsetmessages: + msg3157
2010-11-29 00:00:00adminsetstatus: tentatively ready -> dr
2010-10-18 00:00:00adminsetmessages: + msg2977
2010-10-18 00:00:00adminsetstatus: drafting -> tentatively ready
2010-08-02 00:00:00admincreate