<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 3018</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="3018"></A><H4>3018.
  
Validity of <TT>defined</TT> in <TT>__has_embed</TT>
</H4>
<B>Section: </B>15.2&#160; [<A href="https://wg21.link/cpp.cond">cpp.cond</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Hubert Tong
 &#160;&#160;&#160;

 <B>Date: </B>2025-03-24<BR>


<P>[Accepted as a DR at the June, 2025 meeting.]</P>

<P>(From submission
<A HREF="https://github.com/cplusplus/CWG/issues/694">#694</A>.)</P>

<P>Is the use of <TT>defined</TT> valid in <TT>__has_embed</TT>?  It
is not valid in cases where it would be interpreted by
the <TT>#if</TT> rules in <TT>#embed</TT>; see
15.4.2.1 [<A href="https://wg21.link/cpp.embed.param.limit#1">cpp.embed.param.limit</A>] paragraph 1.</P>

<P>To avoid confusion, <TT>defined</TT> should also be prohibited
inside <TT>__has_embed</TT>.</P>

<P><B>Proposed resolution (approved by CWG 2025-06-20):</B></P>

<OL>
<LI>
<P>Change in 15.2 [<A href="https://wg21.link/cpp.cond#1">cpp.cond</A>] paragraph 1 as follows:</P>


<BLOCKQUOTE>

The expression that controls conditional inclusion shall be an
integral constant expression except that identifiers (including those
lexically identical to keywords) are interpreted as described below123
and it may contain zero or more <I>defined-macro-expression</I>s,
<I>has-include-expression</I>s, <I>has-attribute-expression</I>s,
and/or <I>has-embed-expression</I>s as unary operator expressions.
<INS>A <I>defined-macro-expression</I> shall not appear within
a <I>has-include-expression</I> or <I>has-embed-expression</I>.</INS>

</BLOCKQUOTE>
</LI>

<LI>
<P>Change in 15.4.2.1 [<A href="https://wg21.link/cpp.embed.param.limit#1">cpp.embed.param.limit</A>] paragraph 1 as follows:</P>

<BLOCKQUOTE>

<P>
An <I>embed-parameter</I> of the form
<TT>limit ( <I>pp-balanced-token-seq</I> )</TT> specifies the maximum
possible number of elements in the comma-delimited list. It shall
appear at most once in
the <I>embed-parameter-seq</I>. The <INS>preprocessing</INS>
token <TT>defined</TT> shall not appear in the
<DEL><I>constant-expression</I></DEL>
<INS><I>pp-balanced-token-seq</I></INS>.</P>

<P>
The <I>pp-balanced-token-seq</I> is evaluated as
a <I>constant-expression</I> using the rules as described in
conditional inclusion (15.2 [<A href="https://wg21.link/cpp.cond">cpp.cond</A>]), but without being
processed as in normal text an additional time.</P>

</BLOCKQUOTE>
</LI>
</OL>

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