<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 2818</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="2818"></A><H4>2818.
  
Use of predefined reserved identifiers
</H4>
<B>Section: </B>5.11&#160; [<A href="https://wg21.link/lex.name">lex.name</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Jiang An
 &#160;&#160;&#160;

 <B>Date: </B>2023-01-18<BR>


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

<P>Subclause 5.11 [<A href="https://wg21.link/lex.name#3">lex.name</A>] paragraph 3 specifies:</P>

<BLOCKQUOTE>

In addition, some identifiers appearing as a <I>token</I> or
<I>preprocessing-token</I> are reserved for use by C++ implementations
and shall not be used otherwise; no diagnostic is required.
<UL>
<LI>
Each identifier that contains a double underscore <TT>__</TT>
or begins with an underscore followed by an uppercase letter is
reserved to the implementation for any use. </LI>
<LI>Each identifier
that begins with an underscore is reserved to the implementation for
use as a name in the global namespace.</LI>
</UL>

</BLOCKQUOTE>

<P>That implies that uses of standard-specified predefined macros
(15.12 [<A href="https://wg21.link/cpp.predefined">cpp.predefined</A>]) or feature-test macros
(17.3.2 [<A href="https://wg21.link/version.syn">version.syn</A>]) make the program ill-formed. This does
not appear to be the intent.</P>

<P><B>Proposed resolution (approved by CWG 2024-01-19) [SUPERSEDED]:</B></P>

<P>Change in 5.11 [<A href="https://wg21.link/lex.name#3">lex.name</A>] paragraph 3 and add bullets as follows:</P>

<BLOCKQUOTE>

In addition, some identifiers appearing as a <I>token</I> or
<I>preprocessing-token</I> are reserved for use by C++ implementations
and shall not be used otherwise; no diagnostic is required.
<UL>
<LI>Each identifier that contains a double underscore <TT>__</TT> or
begins with an underscore followed by an uppercase letter is reserved
to the implementation for any use<INS>, except for</INS>
<UL class="ins">
<LI>the macros specified in 15.12 [<A href="https://wg21.link/cpp.predefined">cpp.predefined</A>],</LI>
<LI>the function-local predefined variable
(9.6.1 [<A href="https://wg21.link/dcl.fct.def.general">dcl.fct.def.general</A>]), and</LI>
<LI>the macros and identifiers declared in the standard library as
specified in Clause 17 [<A href="https://wg21.link/support">support</A>] through Clause 32 [<A href="https://wg21.link/thread">thread</A>],
and Clause Annex D [<A href="https://wg21.link/depr">depr</A>].  [ Note: This affects macros in
17.3.2 [<A href="https://wg21.link/version.syn">version.syn</A>], 31.13.1 [<A href="https://wg21.link/cstdio.syn">cstdio.syn</A>], and
D.11 [<A href="https://wg21.link/depr.c.macros">depr.c.macros</A>] as well as identifiers in
17.2.2 [<A href="https://wg21.link/cstdlib.syn">cstdlib.syn</A>]. -- end note ]
</LI>
</UL>
</LI>
<LI>Each identifier that begins with an underscore is reserved to the
implementation for use as a name in the global namespace.</LI>
</UL>

</BLOCKQUOTE>

<P><B>CWG 2024-03-20</B></P>

<P>The exceptions should not be specified using a specific list,
which might become stale in the future.</P>

<P><B>Proposed resolution (approved by CWG 2024-03-20):</B></P>

<P>Change in 5.11 [<A href="https://wg21.link/lex.name#3">lex.name</A>] paragraph 3 and add bullets as follows:</P>

<BLOCKQUOTE>

In addition, some identifiers appearing as a <I>token</I> or
<I>preprocessing-token</I> are reserved for use by C++ implementations
and shall not be used otherwise; no diagnostic is required.
<UL>
<LI>Each identifier that contains a double underscore <TT>__</TT> or
begins with an underscore followed by an uppercase letter<INS>, other
than those specified in this document (for
example, <TT>__cplusplus</TT> (15.12 [<A href="https://wg21.link/cpp.predefined">cpp.predefined</A>])), </INS> is
reserved to the implementation for any use.
</LI>
<LI>Each identifier that begins with an underscore is reserved to the
implementation for use as a name in the global namespace.</LI>
</UL>

</BLOCKQUOTE>

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