|
| 1 | +<HTML> |
| 2 | +<HEAD> |
| 3 | +<meta http-equiv="Content-Type" content="text/html; charset=us-ascii"> |
| 4 | +<TITLE> |
| 5 | + CWG Issue 2912</TITLE> |
| 6 | +<STYLE TYPE="text/css"> |
| 7 | + INS { text-decoration:none; font-weight:bold; background-color:#A0FFA0 } |
| 8 | + .INS { text-decoration:none; background-color:#D0FFD0 } |
| 9 | + DEL { text-decoration:line-through; background-color:#FFA0A0 } |
| 10 | + .DEL { text-decoration:line-through; background-color: #FFD0D0 } |
| 11 | + SPAN.cmnt { font-family:Times; font-style:italic } |
| 12 | +</STYLE> |
| 13 | +</HEAD> |
| 14 | +<BODY> |
| 15 | +<P><EM>This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 |
| 16 | + Core Issues List revision 114b. |
| 17 | + See http://www.open-std.org/jtc1/sc22/wg21/ for the official |
| 18 | + list.</EM></P> |
| 19 | +<P>2024-06-26</P> |
| 20 | +<HR> |
| 21 | +<A NAME="2912"></A><H4>2912. |
| 22 | + |
| 23 | +Too-large value for size in array new |
| 24 | +</H4> |
| 25 | +<B>Section: </B>7.6.2.8  [<A href="https://wg21.link/expr.new">expr.new</A>] |
| 26 | +     |
| 27 | + |
| 28 | + <B>Status: </B>open |
| 29 | +     |
| 30 | + |
| 31 | + <B>Submitter: </B>Mital Ashok |
| 32 | +     |
| 33 | + |
| 34 | + <B>Date: </B>2024-06-20<BR> |
| 35 | + |
| 36 | + |
| 37 | +<P>(From submission |
| 38 | +<A HREF="https://github.com/cplusplus/CWG/issues/560">#560</A>.)</P> |
| 39 | + |
| 40 | +<P>Consider an implementation with a <TT>size_t</TT> smaller |
| 41 | +than <TT>long long</TT>. An implementation should flag too-large |
| 42 | +values for the size in an array "new", in the same manner it flags |
| 43 | +negative values. For example:</P> |
| 44 | +<PRE> |
| 45 | + int *p = new int[ULLONG_MAX]; |
| 46 | +</PRE> |
| 47 | + |
| 48 | +<P><U>Possible resolution:</U></P> |
| 49 | + |
| 50 | +<P>Change in 7.6.2.8 [<A href="https://wg21.link/expr.new#8">expr.new</A>] paragraph 8 as follows:</P> |
| 51 | + |
| 52 | +<BLOCKQUOTE> |
| 53 | + |
| 54 | +If the expression in a <I>noptr-new-declarator</I> is present, it is |
| 55 | +implicitly converted to std::size_t. The value of the expression is |
| 56 | +invalid if: |
| 57 | +<UL> |
| 58 | +<LI>the expression is of non-class type and its value before |
| 59 | +converting to std::size_t is less than zero <INS>or greater than the |
| 60 | +maximum value representable as a <TT>std::size_t</TT></INS>; |
| 61 | +</LI> |
| 62 | +<LI>the expression is of class type and its value before application |
| 63 | +of the second standard conversion (12.2.4.2.3 [<A href="https://wg21.link/over.ics.user">over.ics.user</A>]) [ |
| 64 | +Footnote: ... ] is less than zero <INS>or greater than the maximum |
| 65 | +value representable as a <TT>std::size_t</TT></INS>;</LI> |
| 66 | +<LI>its value is such that the size of the allocated object would |
| 67 | +exceed the implementation-defined limit (Annex B); or |
| 68 | +</LI> |
| 69 | +<LI>the <I>new-initializer</I> is a <I>braced-init-list</I> and the |
| 70 | +number of array elements for which initializers are provided |
| 71 | +(including the terminating '\0' in a <I>string-literal</I> |
| 72 | +(5.13.5 [<A href="https://wg21.link/lex.string">lex.string</A>])) exceeds the number of elements to |
| 73 | +initialize.</LI> |
| 74 | +</UL> |
| 75 | + |
| 76 | +</BLOCKQUOTE> |
| 77 | + |
| 78 | +<BR><BR> |
| 79 | +</BODY> |
| 80 | +</HTML> |
0 commit comments