This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115e. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-11-11
(From submission #560.)
Consider an implementation with a size_t smaller than long long. An implementation should flag too-large values for the size in an array "new", in the same manner it flags negative values. For example:
int *p = new int[ULLONG_MAX];
Possible resolution:
Change in 7.6.2.8 [expr.new] paragraph 8 as follows:
If the expression in a noptr-new-declarator is present, it is implicitly converted to std::size_t. The value of the expression is invalid if:
- the expression is of non-class type and its value before converting to std::size_t is less than zero or greater than the maximum value representable as a std::size_t;
- the expression is of class type and its value before application of the second standard conversion (12.2.4.2.3 [over.ics.user]) [ Footnote: ... ] is less than zero or greater than the maximum value representable as a std::size_t;
- its value is such that the size of the allocated object would exceed the implementation-defined limit (Annex B); or
- the new-initializer is a braced-init-list and the number of array elements for which initializers are provided (including the terminating '\0' in a string-literal (5.13.5 [lex.string])) exceeds the number of elements to initialize.