<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 2494</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="2494"></A><H4>2494.
  
Multiple definitions of non-odr-used entities
</H4>
<B>Section: </B>6.3&#160; [<A href="https://wg21.link/basic.def.odr">basic.def.odr</A>]
 &#160;&#160;&#160;

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

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

 <B>Date: </B>2021-07-02<BR>


<P>[Accepted at the February, 2022 meeting.]</P>



<P>According to 6.3 [<A href="https://wg21.link/basic.def.odr#10">basic.def.odr</A>] paragraph 10,</P>

<BLOCKQUOTE>

Every program shall contain exactly one definition of every non-inline
function or variable that is odr-used in that program outside of a
discarded statement (8.5.2 [<A href="https://wg21.link/stmt.if">stmt.if</A>]); no diagnostic required.

</BLOCKQUOTE>

<P>This wording could be interpreted as allowing multiple
definitions of non-inline variables and functions if they
are not odr-used. That is presumably not the intent.</P>

<P><B>Notes from the August, 2021 teleconference:</B></P>

<P>CWG observed that there is a similar problem in paragraph
13. See also <A HREF="1849.html">issue 1849</A>.</P>

<P><B>Proposed resolution, December, 2021:</B></P>

<OL>
<LI><P>Change 6.3 [<A href="https://wg21.link/basic.def.odr#1">basic.def.odr</A>] paragraph 1 as follows:</P></LI>

<BLOCKQUOTE>

<P><INS>Each of the following is termed a <I>definable
item:</I></INS></P>

<UL>
<LI><P><INS>a class type (
Clause 11 [<A href="https://wg21.link/class">class</A>]),</INS></P></LI>

<LI><P><INS>an enumeration type (9.8.1 [<A href="https://wg21.link/dcl.enum">dcl.enum</A>]),</INS></P></LI>

<LI><P><INS>a function (9.3.4.6 [<A href="https://wg21.link/dcl.fct">dcl.fct</A>]),</INS></P></LI>

<LI><P><INS>a variable (6.1 [<A href="https://wg21.link/basic.pre">basic.pre</A>]),</INS></P></LI>

<LI><P><INS>a templated entity (13.1 [<A href="https://wg21.link/temp.pre">temp.pre</A>]),</INS></P></LI>

<LI><P><INS>a default argument for a parameter (for a function
in a given scope) (9.3.4.7 [<A href="https://wg21.link/dcl.fct.default">dcl.fct.default</A>]), or</INS></P></LI>

<LI><P><INS>a default template argument
(13.2 [<A href="https://wg21.link/temp.param">temp.param</A>]).</INS></P></LI>

</UL>

<P>No translation unit shall contain more than one definition
of any <DEL>variable, function, class type, enumeration type,
template, default argument for a parameter (for a function
in a given scope), or default template argument</DEL>
<INS>definable item</INS>.</P>

</BLOCKQUOTE>

<LI><P>Change 6.3 [<A href="https://wg21.link/basic.def.odr#10">basic.def.odr</A>] paragraph 10 as follows:</P></LI>

<BLOCKQUOTE>

Every program shall contain <DEL>exactly</DEL> <INS>at
least</INS> one definition of every <DEL>non-inline</DEL>
function or variable that is odr-used in that program
outside of a discarded statement
(8.5.2 [<A href="https://wg21.link/stmt.if">stmt.if</A>]); no diagnostic required. The
definition...

</BLOCKQUOTE>

<LI><P>Change 6.3 [<A href="https://wg21.link/basic.def.odr#13">basic.def.odr</A>] paragraph 13 as follows:</P></LI>

<BLOCKQUOTE>

<P><DEL>There can be more than one definition of a</DEL></P>

<UL>
<LI><P>
<DEL>class type (Clause 11 [<A href="https://wg21.link/class">class</A>]),</DEL>
</P></LI>

<LI><P>
<DEL>enumeration type (9.8.1 [<A href="https://wg21.link/dcl.enum">dcl.enum</A>]),</DEL>
</P></LI>

<LI><P>
<DEL>inline function or variable (9.2.8 [<A href="https://wg21.link/dcl.inline">dcl.inline</A>]),</DEL>
</P></LI>

<LI><P>
<DEL>templated entity (13.1 [<A href="https://wg21.link/temp.pre">temp.pre</A>]),</DEL>
</P></LI>

<LI><P>
<DEL>default argument for a parameter (for a function in a given
scope) (9.3.4.7 [<A href="https://wg21.link/dcl.fct.default">dcl.fct.default</A>]), or</DEL>
</P></LI>

<LI><P>
<DEL>default template argument (13.2 [<A href="https://wg21.link/temp.param">temp.param</A>])</DEL>
</P></LI>

</UL>

<P>
<DEL>in a program provided that each definition appears in a
different translation unit and the definitions satisfy the
following requirements.</DEL> <INS>For any definable item
<TT>D</TT> with definitions in multiple translation units,</INS>
</P>

<UL>
<LI><P><INS>if <TT>D</TT> is a non-inline non-templated
function or variable, or</INS></P></LI>

<LI><P><INS>if the definitions in different translation
units do not satisfy the following requirements,</INS></P></LI>

</UL>

<P>
<INS>the program is ill-formed; a diagnostic is required only if the
definable item is attached to a named module and a prior definition is
reachable at the point where a later definition occurs.</INS> Given such
an <DEL>entity <TT>D</TT> defined in more than one translation
unit</DEL> <INS>item</INS>, for all definitions of <TT>D</TT>, or,
if <TT>D</TT> is an unnamed enumeration, for all definitions of <TT>D</TT>
that are reachable at any given program point, the following requirements
shall be satisfied...</P>

</BLOCKQUOTE>

<LI><P>Delete 6.3 [<A href="https://wg21.link/basic.def.odr#15">basic.def.odr</A>] paragraph 15:</P></LI>

<BLOCKQUOTE>

<DEL>If these definitions do not satisfy these requirements, then
the program is ill-formed; a diagnostic is required only if
the entity is attached to a named module and a prior
definition is reachable at the point where a later
definition occurs.</DEL>

</BLOCKQUOTE>

</OL>

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