Title
Can size_t and ptrdiff_t be larger than long?
Status
nad
Section
7.6.6 [expr.add]
Submitter
Nick MacLaren

Created on 2006-03-14.00:00:00 last changed 212 months ago

Messages

Date: 2006-10-15.00:00:00

Rationale (October, 2006):

This is not an area in which the Standard should override the decisions of implementors who wish to maintain the size of long for backward compatibility but need a larger size_t to deal with expanded address spaces. Also, diagnostics of the sort described are better treated as quality of implementation issues rather than topics for standardization.

Date: 2022-11-20.07:54:16

Code that was portable in C90 and C++98 is no longer portable with the introduction of data types longer than long; code that could previously cast size_t and ptrdiff_t to long without loss of precision (because long was the largest type) can no longer rely on that idiom.

The CWG discussed this during the Berlin (April, 2006) meeting. The general consensus was that this was unavoidable: there are valid reasons for implementations to keep long at a size less than that required for address arithmetic.

See paper J16/06-0053 = WG21 N1983, which also suggests the possibility of required diagnostics for problematic cases as an alternative to restricting the size of size_t and ptrdiff_t.

History
Date User Action Args
2006-11-05 00:00:00adminsetmessages: + msg1454
2006-11-05 00:00:00adminsetstatus: open -> nad
2006-03-14 00:00:00admincreate