<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 1850</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="1850"></A><H4>1850.
  
Differences between definition context and point of instantiation
</H4>
<B>Section: </B>13.8&#160; [<A href="https://wg21.link/temp.res">temp.res</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Richard Smith
 &#160;&#160;&#160;

 <B>Date: </B>2014-02-04<BR>


<P>[Moved to DR at the November, 2014 meeting.]</P>



<P>Various characteristics of entities referred to by a non-dependent
reference in a template can change between the definition context and
the point of instantiation of a specialization of that template.  These
include initialization (which affects whether an object can be used
in a constant expression), function and template default arguments,
and the completeness of types.  There is implementation divergence
as to whether these are checked in the definition context or at the
point of instantiation.  Presumably a rule is needed to make it
ill-formed, no diagnostic required, if the validity of such a
reference changes between the two contexts.</P>

<P><B>Proposed resolution (February, 2014):</B></P>

<P>Change 13.8 [<A href="https://wg21.link/temp.res#8">temp.res</A>] paragraph 8 as follows:</P>

<BLOCKQUOTE>

...If a <DEL>type used in a non-dependent name is incomplete at the point
at which a template is defined but is complete at the point at which an
instantiation is done, and if the completeness of that type affects whether
or not the program is well-formed or affects the semantics of the
program,</DEL> <INS>hypothetical instantiation of a template immediately
following its definition would be ill-formed due to a construct that does
not depend on a template parameter, the program is ill-formed; no
diagnostic is required.  If the interpretation of such a construct in the
hypothetical instantiation is different from the interpretation of the
corresponding construct in any actual instantiation of the template,</INS>
the program is ill-formed; no diagnostic is required. <INS>[<I>Note:</I>
This can happen in situations including the following:</INS>

<UL>
<LI><P><INS>a type used in a non-dependent name is incomplete at the
point at which a template is defined but is complete at the point at which
an instantiation is performed, or</INS></P></LI>

<LI><P><INS>an instantiation uses a default argument or default template
argument that had not been defined at the point at which the template was
defined, or</INS></P></LI>

<LI><P><INS>constant expression evaluation (7.7 [<A href="https://wg21.link/expr.const">expr.const</A>]) within
the template instantiation uses</INS></P></LI>

<UL>
<LI><INS>the value of a <TT>const</TT> object of integral or unscoped
enumeration type or</INS></LI>

<LI><P><INS>the value of a <TT>constexpr</TT> object or</INS></P></LI>

<LI><P><INS>the value of a reference or</INS></P></LI>

<LI><P><INS>the definition of a <TT>constexpr</TT> function,</INS></P></LI>

</UL>

<P><INS>and that entity was not defined when the template was defined,
or</INS></P>

<LI><P><INS>a class template specialization or variable template
specialization that is specified by a non-dependent
<I>simple-template-id</I> is used by the template, and either it is
instantiated from a partial specialization that was not defined when the
template was defined or it names an explicit specialization that was
not declared when the template was defined.</INS></P></LI>

</UL>

<P>
<INS>&#8212;<I>end note</I>]</INS> [<I>Note:</I> If a
template is instantiated...</P>

</BLOCKQUOTE>

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