<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 299</TITLE>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<STYLE TYPE="text/css">
  INS { text-decoration:none; font-weight:bold; background-color:#A0FFA0 }
  .INS { text-decoration:none; background-color:#D0FFD0 }
  DEL { text-decoration:line-through; background-color:#FFA0A0 }
  .DEL { text-decoration:line-through; background-color: #FFD0D0 }
  @media (prefers-color-scheme: dark) {
    HTML { background-color:#202020; color:#f0f0f0; }
    A { color:#5bc0ff; }
    A:visited { color:#c6a8ff; }
    A:hover, a:focus { color:#afd7ff; }
    INS { background-color:#033a16; color:#aff5b4; }
    .INS { background-color: #033a16; }
    DEL { background-color:#67060c; color:#ffdcd7; }
    .DEL { background-color:#67060c; }
  }
  SPAN.cmnt { font-family:Times; font-style:italic }
</STYLE>
</HEAD>
<BODY>
<P><EM>This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21
  Core Issues List revision 118b.
  See http://www.open-std.org/jtc1/sc22/wg21/ for the official
  list.</EM></P>
<P>2025-09-28</P>
<HR>
<A NAME="299"></A><H4>299.
  
Conversion on array bound expression in <TT>new</TT>
</H4>
<B>Section: </B>7.6.2.8&#160; [<A href="https://wg21.link/expr.new">expr.new</A>]
 &#160;&#160;&#160;

 <B>Status: </B>CD1
 &#160;&#160;&#160;

 <B>Submitter: </B>Mark Mitchell
 &#160;&#160;&#160;

 <B>Date: </B>19 Jul 2001<BR>


<P>[Voted into WP at October 2005 meeting.]</P>



<P>In 7.6.2.8 [<A href="https://wg21.link/expr.new">expr.new</A>], the standard says that the
expression in an array-new has to
have integral type.  There's already a DR (<A HREF="74.html">issue 74</A>)
that says it should also be allowed to have enumeration type.  But, it should
probably also say that it can have a class type with a single
conversion to integral type; in other words the same thing as in
8.5.3 [<A href="https://wg21.link/stmt.switch#2">stmt.switch</A>] paragraph 2.</P>

<P><B>Suggested resolution:</B></P>

<P>In 7.6.2.8 [<A href="https://wg21.link/expr.new#6">expr.new</A>] paragraph 6, replace
"integral or enumeration type (6.9.2 [<A href="https://wg21.link/basic.fundamental">basic.fundamental</A>])" with
"integral or enumeration type (6.9.2 [<A href="https://wg21.link/basic.fundamental">basic.fundamental</A>]), or a class
type for which a single conversion function to
integral or enumeration type exists".</P>

<P><B>Proposed resolution (October, 2004):</B></P>

<P>Change 7.6.2.8 [<A href="https://wg21.link/expr.new#6">expr.new</A>] paragraph 6 as
follows:</P>

<BLOCKQUOTE>

Every <I>constant-expression</I> in a
<I>direct-new-declarator</I> shall be an integral constant
expression (7.7 [<A href="https://wg21.link/expr.const">expr.const</A>]) and evaluate to a
strictly positive value. The <I>expression</I> in a
<I>direct-new-declarator</I> shall <DEL>have</DEL> <INS>be of</INS>
integral type, <DEL>or</DEL> enumeration type<DEL> (3.9.1)</DEL><INS>, or a
class type for which a single conversion function to integral or
enumeration type exists (11.4.8 [<A href="https://wg21.link/class.conv">class.conv</A>]). If the
expression is of class type, the expression is converted by
calling the conversion function, and the result of the conversion
is used in place of the original expression. The value of the
expression shall be</INS><DEL>with a</DEL> non-negative<DEL>
value</DEL>. [<I>Example:</I> ...

</BLOCKQUOTE>

<P><B>Proposed resolution (April, 2005):</B></P>

<P>Change 7.6.2.8 [<A href="https://wg21.link/expr.new#6">expr.new</A>] paragraph 6 as
follows:</P>

<BLOCKQUOTE>

Every <I>constant-expression</I> in a
<I>direct-new-declarator</I> shall be an integral constant
expression (7.7 [<A href="https://wg21.link/expr.const">expr.const</A>]) and evaluate to a
strictly positive value. The <I>expression</I> in a
<I>direct-new-declarator</I> shall <DEL>have integral or enumeration
type (6.9.2 [<A href="https://wg21.link/basic.fundamental">basic.fundamental</A>]) with a non-negative
value</DEL> <INS>be of integral type, enumeration type, or a class type for
which a single conversion function to integral or enumeration type
exists (11.4.8 [<A href="https://wg21.link/class.conv">class.conv</A>]). If the expression is of class
type, the expression is converted by calling that conversion function,
and the result of the conversion is used in place of the original
expression. If the value of the expression is negative, the behavior
is undefined</INS>. [<I>Example:</I> ...

</BLOCKQUOTE>

<BR><BR>
</BODY>
</HTML>
