<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 605</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="605"></A><H4>605.
  
Linkage of explicit specializations
</H4>
<B>Section: </B>13.9.4&#160; [<A href="https://wg21.link/temp.expl.spec">temp.expl.spec</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Steve Clamage
 &#160;&#160;&#160;

 <B>Date: </B>30 November 2006<BR>


<P>[Voted into WP at August, 2010 meeting.]</P>



<P>Given</P>

<PRE>
    template &lt;class T&gt; static T f(T   t) { ... }
    template &lt;&gt;             int f(int t) { ... }
</PRE>

<P>what is the linkage of <TT>f(int)</TT>?</P>

<P>Section Clause 13 [<A href="https://wg21.link/temp#4">temp</A>] paragraph 4 says,</P>

<BLOCKQUOTE>

Entities generated from a template with internal linkage are
distinct from all entities generated in other translation units.

</BLOCKQUOTE>

<P>But is the explicit specialization &#8220;generated
from&#8221; the primary template?  Does it inherit the local
linkage?  If so, where do I find a reference saying so
explicitly?</P>

<P>
<U>James Widman</U>: Data points: EDG 3.8 inherits, GCC 4.0
does not.</P>

<P>
<U>Mike Miller</U>: There's a pretty strong presumption that
the linkage of an explicit specialization cannot be different
from that of its primary template, given that storage class
specifiers cannot appear in an explicit specialization
(9.2.2 [<A href="https://wg21.link/dcl.stc#1">dcl.stc</A>] paragraph 1).</P>

<P><B>Notes from the April, 2007 meeting:</B></P>

<P>The CWG agreed that the linkage of an explicit specialization
must be that of the template.  Gabriel Dos Reis will investigate
the reason for the different behavior of g++.</P>

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

<P>Change Clause 13 [<A href="https://wg21.link/temp#4">temp</A>] paragraph 4 as follows:</P>

<BLOCKQUOTE>

...<DEL>Entities generated from</DEL> <INS>Specializations
(explicit or implicit) of</INS> a template <DEL>with</DEL>
<INS>that has</INS> internal linkage are distinct from all
<DEL>entities generated</DEL> <INS>specializations</INS> in other
translation units...

</BLOCKQUOTE>

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