<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 837</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="837"></A><H4>837.
  
Constexpr functions and <TT>return</TT> <I>braced-init-list</I>
</H4>
<B>Section: </B>9.2.6&#160; [<A href="https://wg21.link/dcl.constexpr">dcl.constexpr</A>]
 &#160;&#160;&#160;

 <B>Status: </B>C++11
 &#160;&#160;&#160;

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>11 March, 2009<BR>


<P>[Voted into the WP at the March, 2011 meeting as part of paper N3268.]</P>

<P>The body of a constexpr function is required by
9.2.6 [<A href="https://wg21.link/dcl.constexpr#3">dcl.constexpr</A>] paragraph 3 to be of the form</P>

<UL>
<TT>{ return</TT> <I>expression</I><TT>; }</TT>
</UL>

<P>However, there does not seem to be any good reason for prohibiting
the alternate return syntax involving a <I>braced-init-list</I>.
The restriction should be removed.</P>

<P><B>Proposed resolution (March, 2010):</B></P>

<OL>
<LI><P>Change 8.8.4 [<A href="https://wg21.link/stmt.return#2">stmt.return</A>] paragraph 2 as follows:</P></LI>

<BLOCKQUOTE>

A return statement <DEL>without an expression</DEL> <INS>with neither an
<I>expression</I> nor a <I>braced-init-list</I></INS> can be used only
in functions that do not return a value...

</BLOCKQUOTE>

<LI><P>Change 9.2.6 [<A href="https://wg21.link/dcl.constexpr#3">dcl.constexpr</A>] paragraph 3 bullets 4
and 5 as follows:</P></LI>

<UL>
<LI>
<P>its <I>function-body</I> shall be a <I>compound-statement</I>
of the form</P>

<UL>
<TT>{ return </TT><I>expression</I><TT> ; }</TT>
</UL>

<P>where <I>expression</I> is a potential constant expression
(5.19)<INS>, or</INS>
</P>

<UL><INS><TT>{ return </TT><I>braced-init-list</I><TT> ; }</TT></INS></UL>

<P><INS>where every <I>assignment-expression</I> that is an
<I>initializer-clause</I> appearing directly or indirectly within the
<I>braced-init-list</I> is a potential constant expression</INS></P>

</LI>

<LI><P>every <INS>constructor call and</INS> implicit conversion
used in <DEL>converting <I>expression</I> to the function return
type</DEL> <INS>initializing the return value</INS>
(<INS>8.8.4 [<A href="https://wg21.link/stmt.return">stmt.return</A>],</INS> 9.5 [<A href="https://wg21.link/dcl.init">dcl.init</A>])
shall be one of those allowed in a constant expression
(7.7 [<A href="https://wg21.link/expr.const">expr.const</A>]).</P></LI>

</UL>

</OL>

<P><B>Notes from the March, 2010 meeting:</B></P>

<P>The new wording added in 7.7 [<A href="https://wg21.link/expr.const">expr.const</A>] in support
of reference parameters for constexpr functions should also be
considered to see whether additional changes are needed.</P>

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