[basic.def.odr]

# 6 Basics [[basic]](./#basic)

## 6.3 One-definition rule [basic.def.odr]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L366)

Each of the following is termed a [*definable item*](#def:item,definable "6.3 One-definition rule [basic.def.odr]"):

- [(1.1)](#1.1)

a class type ([[class]](class "11 Classes")),

- [(1.2)](#1.2)

an enumeration type ([[dcl.enum]](dcl.enum "9.8.1 Enumeration declarations")),

- [(1.3)](#1.3)

a function ([[dcl.fct]](dcl.fct "9.3.4.6 Functions")),

- [(1.4)](#1.4)

a variable ([[basic.pre]](basic.pre "6.1 Preamble")),

- [(1.5)](#1.5)

a templated entity ([[temp.pre]](temp.pre "13.1 Preamble")),

- [(1.6)](#1.6)

a default argument for a parameter
(for a function in a given scope) ([[dcl.fct.default]](dcl.fct.default "9.3.4.7 Default arguments")), or

- [(1.7)](#1.7)

a default template argument ([[temp.param]](temp.param "13.2 Template parameters"))[.](#1.sentence-1)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L379)

No translation unit shall contain more than one definition of any
definable item[.](#2.sentence-1)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L383)

An expression or conversion is [*potentially evaluated*](#def:potentially_evaluated "6.3 One-definition rule [basic.def.odr]") unless it is
an unevaluated operand ([[expr.context]](expr.context "7.2.3 Context dependence")),
a subexpression thereof, or
a conversion in an initialization or conversion sequence in such a context[.](#3.sentence-1)

The set of [*potential results*](#def:potential_results "6.3 One-definition rule [basic.def.odr]") of an expression E is
defined as follows:

- [(3.1)](#3.1)

  If E is
an [*id-expression*](expr.prim.id.general#nt:id-expression "7.5.5.1 General [expr.prim.id.general]") ([[expr.prim.id]](expr.prim.id "7.5.5 Names")) or
a [*splice-expression*](expr.prim.splice#nt:splice-expression "7.5.9 Expression splicing [expr.prim.splice]") ([[expr.prim.splice]](expr.prim.splice "7.5.9 Expression splicing")), the set
contains only E[.](#3.1.sentence-1)

- [(3.2)](#3.2)

  If E is a [subscripting](expr.sub "7.6.1.2 Subscripting [expr.sub]") operation with
an array operand, the set contains the potential results of that operand[.](#3.2.sentence-1)

- [(3.3)](#3.3)

  If E is a class member access
expression ([[expr.ref]](expr.ref "7.6.1.5 Class member access")) of the formE1 . templateopt E2 naming a non-static data member,
the set contains the potential results of E1[.](#3.3.sentence-1)

- [(3.4)](#3.4)

  If E is a class member access expression
naming a static data member,
the set contains the [*id-expression*](expr.prim.id.general#nt:id-expression "7.5.5.1 General [expr.prim.id.general]") designating the data member[.](#3.4.sentence-1)

- [(3.5)](#3.5)

  If E is a [pointer-to-member expression](expr.mptr.oper "7.6.4 Pointer-to-member operators [expr.mptr.oper]") of the formE1 .* E2,
the set contains the potential results of E1[.](#3.5.sentence-1)

- [(3.6)](#3.6)

  If E has the form (E1), the set contains the
potential results of E1[.](#3.6.sentence-1)

- [(3.7)](#3.7)

  If E is a glvalue [conditional expression](expr.cond "7.6.16 Conditional operator [expr.cond]"),
the set is the union of the sets of
potential results of the second and third operands[.](#3.7.sentence-1)

- [(3.8)](#3.8)

  If E is a [comma expression](expr.comma "7.6.20 Comma operator [expr.comma]"), the set
contains the potential results of the right operand[.](#3.8.sentence-1)

- [(3.9)](#3.9)

  Otherwise, the set is empty[.](#3.9.sentence-1)

[*Note [1](#note-1)*:

This set is a (possibly-empty) set of[*id-expression*](expr.prim.id.general#nt:id-expression "7.5.5.1 General [expr.prim.id.general]")*s* and [*splice-expression*](expr.prim.splice#nt:splice-expression "7.5.9 Expression splicing [expr.prim.splice]")*s*,
each of which is either E or a subexpression of E[.](#3.sentence-3)

[*Example [1](#example-1)*:

In the following example, the set of potential results of the initializer
of n contains the first S​::​x subexpression, but not the secondS​::​x subexpression[.](#3.sentence-4)

The set of potential results of the initializer of o contains
the subexpression [:^^S​::​x:][.](#3.sentence-5)

struct S { static const int x = 0; };const int &f(const int &r);int n = b ? (1, S::x) // S​::​x is not odr-used here: f(S::x); // S​::​x is odr-used here, so a definition is requiredint o = [:^^S::x:]; â *end example*]

â *end note*]

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L438)

A function is [*named by*](#def:function,named_by_expression_or_conversion "6.3 One-definition rule [basic.def.odr]") an expression or conversion as follows:

- [(4.1)](#4.1)

  A function is named by an expression or conversion
 if it is the selected member
 of an overload set ([[basic.lookup]](basic.lookup "6.5 Name lookup"), [[over.match]](over.match "12.2 Overload resolution"), [[over.over]](over.over "12.3 Address of an overload set"))
 in an overload resolution performed
 as part of forming that expression or conversion,
 and either
 it is not a pure virtual function or
 the expression is an [*id-expression*](expr.prim.id.general#nt:id-expression "7.5.5.1 General [expr.prim.id.general]") naming the function with
 an explicitly qualified name
 that does not form a pointer to member ([[expr.unary.op]](expr.unary.op "7.6.2.2 Unary operators"))[.](#4.1.sentence-1)
  [*Note [2](#note-2)*:
  This covers
 taking the address of functions ([[conv.func]](conv.func "7.3.4 Function-to-pointer conversion"), [[expr.unary.op]](expr.unary.op "7.6.2.2 Unary operators")),
 calls to named functions ([[expr.call]](expr.call "7.6.1.3 Function call")),
 operator overloading ([[over]](over "12 Overloading")),
 user-defined conversions ([[class.conv.fct]](class.conv.fct "11.4.8.3 Conversion functions")),
 allocation functions for [*new-expression*](expr.new#nt:new-expression "7.6.2.8 New [expr.new]")*s* ([[expr.new]](expr.new "7.6.2.8 New")), as well as
 non-default initialization ([[dcl.init]](dcl.init "9.5 Initializers"))[.](#4.1.sentence-2)
  A constructor selected to copy or move an object of class type
 is considered to be named by an expression or conversion
 even if the call is actually elided by the implementation ([[class.copy.elision]](class.copy.elision "11.9.6 Copy/move elision"))[.](#4.1.sentence-3)
 â *end note*]

- [(4.2)](#4.2)

  A deallocation function for a class
 is named by a [*new-expression*](expr.new#nt:new-expression "7.6.2.8 New [expr.new]") if it is the single matching deallocation function
 for the allocation function selected by overload resolution,
 as specified in [[expr.new]](expr.new "7.6.2.8 New")[.](#4.2.sentence-1)

- [(4.3)](#4.3)

  A deallocation function for a class
 is named by a [*delete-expression*](expr.delete#nt:delete-expression "7.6.2.9 Delete [expr.delete]") if it is the selected usual deallocation function
 as specified in [[expr.delete]](expr.delete "7.6.2.9 Delete") and [[class.free]](class.free "11.4.11 Allocation and deallocation functions")[.](#4.3.sentence-1)

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L478)

A variable is named by an expression
if the expression is an [*id-expression*](expr.prim.id.general#nt:id-expression "7.5.5.1 General [expr.prim.id.general]") or[*splice-expression*](expr.prim.splice#nt:splice-expression "7.5.9 Expression splicing [expr.prim.splice]") ([[expr.prim.splice]](expr.prim.splice "7.5.9 Expression splicing"))
that designates it[.](#5.sentence-1)

A variable x that is named by a
potentially-evaluated expression N that appears at a point P is [*odr-used*](#def:odr-use "6.3 One-definition rule [basic.def.odr]") by N unless

- [(5.1)](#5.1)

x is a reference
that is usable in constant expressions at P ([[expr.const]](expr.const "7.7 Constant expressions")) or

- [(5.2)](#5.2)

N is an element of the set of potential results of an expression E, where
  * [(5.2.1)](#5.2.1)

E is a discarded-value expression ([[expr.context]](expr.context "7.2.3 Context dependence"))
to which the lvalue-to-rvalue conversion is not applied or

  * [(5.2.2)](#5.2.2)

x is a non-volatile object
that is usable in constant expressions at P and
has no mutable subobjects and
    +
          [(5.2.2.1)](#5.2.2.1)
E is a class member access expression ([[expr.ref]](expr.ref "7.6.1.5 Class member access"))
naming a non-static data member of reference type and
whose object expression has non-volatile-qualified type or

    +
          [(5.2.2.2)](#5.2.2.2)
the lvalue-to-rvalue conversion ([[conv.lval]](conv.lval "7.3.2 Lvalue-to-rvalue conversion")) is applied to E andE has non-volatile-qualified non-class type

[*Example [2](#example-2)*: int f(int);int g(int&);struct A {int x;};struct B {int& r;};int h(bool cond) {constexpr A a = {1}; constexpr const volatile A& r = a; // odr-uses aint _ = f(cond ? a.x : r.x); // does not odr-use a or rint x, y; constexpr B b1 = {x}, b2 = {y}; // odr-uses x and yint _ = g(cond ? b1.r : b2.r); // does not odr-use b1 or b2int _ = ((cond ? x : y), 0); // does not odr-use x or yreturn [] {return b1.r; // error: b1 is odr-used here because the object// referred to by b1.r is not constexpr-referenceable here}();} â *end example*]

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L539)

A structured binding is named by an expression
if that expression is either an [*id-expression*](expr.prim.id.general#nt:id-expression "7.5.5.1 General [expr.prim.id.general]") or
a [*splice-expression*](expr.prim.splice#nt:splice-expression "7.5.9 Expression splicing [expr.prim.splice]") that designates that structured binding[.](#6.sentence-1)

A structured binding is odr-used
if it is named by a potentially-evaluated expression[.](#6.sentence-2)

[7](#7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L547)

*this is odr-used if this appears as a potentially-evaluated expression
(including as the result of any implicit transformation to
a class member access expression ([[expr.prim.id.general]](expr.prim.id.general "7.5.5.1 General")))[.](#7.sentence-1)

[8](#8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L552)

A virtual member
function is odr-used if it is not pure[.](#8.sentence-1)

A function is odr-used if it is named by
a potentially-evaluated expression or conversion[.](#8.sentence-2)

A non-placement allocation or deallocation
function for a class is odr-used by the definition of a constructor of that
class[.](#8.sentence-3)

A non-placement deallocation function for a class is odr-used by the
definition of the destructor of that class, or by being selected by the
lookup at the point of definition of a virtual
destructor ([[class.dtor]](class.dtor "11.4.7 Destructors"))[.](#8.sentence-4)[16](#footnote-16 "An implementation is not required to call allocation and deallocation functions from constructors or destructors; however, this is a permissible implementation technique.")

[9](#9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L570)

An assignment operator function in a class is odr-used by an
implicitly-defined
copy assignment or move assignment function for another class as specified
in [[class.copy.assign]](class.copy.assign "11.4.6 Copy/move assignment operator")[.](#9.sentence-1)

A constructor for a class is odr-used as specified
in [[dcl.init]](dcl.init "9.5 Initializers")[.](#9.sentence-2)

A destructor for a class is odr-used if it is[potentially invoked](class.dtor#def:potentially_invoked "11.4.7 Destructors [class.dtor]")[.](#9.sentence-3)

[10](#10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L579)

A local entity ([[basic.pre]](basic.pre "6.1 Preamble"))
is [*odr-usable*](#def:odr-usable "6.3 One-definition rule [basic.def.odr]") in a scope ([[basic.scope.scope]](basic.scope.scope "6.4.1 General")) if

- [(10.1)](#10.1)

either the local entity is not *this, or
an enclosing class or non-lambda function parameter scope exists and,
if the innermost such scope is a function parameter scope,
it corresponds to a non-static member function, and

- [(10.2)](#10.2)

for each intervening scope ([[basic.scope.scope]](basic.scope.scope "6.4.1 General"))
between the point at which the entity is introduced and the scope
(where *this is considered to be introduced
within the innermost enclosing class or non-lambda function definition scope),
either
  * [(10.2.1)](#10.2.1)

the intervening scope is a block scope,

  * [(10.2.2)](#10.2.2)

the intervening scope is a contract-assertion scope ([[basic.scope.contract]](basic.scope.contract "6.4.10 Contract-assertion scope")),

  * [(10.2.3)](#10.2.3)

the intervening scope is the function parameter scope of
a [*lambda-expression*](expr.prim.lambda.general#nt:lambda-expression "7.5.6.1 General [expr.prim.lambda.general]") or [*requires-expression*](expr.prim.req.general#nt:requires-expression "7.5.8.1 General [expr.prim.req.general]"), or

  * [(10.2.4)](#10.2.4)

the intervening scope is the lambda scope of
a [*lambda-expression*](expr.prim.lambda.general#nt:lambda-expression "7.5.6.1 General [expr.prim.lambda.general]") that has a [*simple-capture*](expr.prim.lambda.capture#nt:simple-capture "7.5.6.3 Captures [expr.prim.lambda.capture]") naming the entity or has a [*capture-default*](expr.prim.lambda.capture#nt:capture-default "7.5.6.3 Captures [expr.prim.lambda.capture]"), and
the block scope of the [*lambda-expression*](expr.prim.lambda.general#nt:lambda-expression "7.5.6.1 General [expr.prim.lambda.general]") is also an intervening scope[.](#10.sentence-1)

If a local entity is odr-used
in a scope in which it is not odr-usable,
the program is ill-formed[.](#10.sentence-2)

[*Example [3](#example-3)*: void f(int n) {[] { n = 1; }; // error: n is not odr-usable due to intervening lambda-expressionstruct A {void f() { n = 2; } // error: n is not odr-usable due to intervening function definition scope}; void g(int = n); // error: n is not odr-usable due to intervening function parameter scope[=](int k = n) {}; // error: n is not odr-usable due to being// outside the block scope of the [*lambda-expression*](expr.prim.lambda.general#nt:lambda-expression "7.5.6.1 General [expr.prim.lambda.general]")[&] { [n]{ return n; }; }; // OK} â *end example*]

[11](#11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L625)

[*Example [4](#example-4)*: void g() {constexpr int x = 1; auto lambda = [] <typename T, int = ((T)x, 0)> {}; // OK lambda.operator()<int, 1>(); // OK, does not consider x at all lambda.operator()<int>(); // OK, does not odr-use x lambda.operator()<const int&>(); // error: odr-uses x from a context where x is not odr-usable}void h() {constexpr int x = 1; auto lambda = [] <typename T> { (T)x; }; // OK lambda.operator()<int>(); // OK, does not odr-use x lambda.operator()<void>(); // OK, does not odr-use x lambda.operator()<const int&>(); // error: odr-uses x from a context where x is not odr-usable} â *end example*]

[12](#12)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L646)

Every program shall contain at least one definition of every
function or variable that is odr-used in that program
outside of a [discarded statement](stmt.if#def:discarded_statement "8.5.2 The if statement [stmt.if]"); no diagnostic required[.](#12.sentence-1)

The definition can appear explicitly in the program, it can be found in
the standard or a user-defined library, or (when appropriate) it is
implicitly defined (see [[class.default.ctor]](class.default.ctor "11.4.5.2 Default constructors"), [[class.copy.ctor]](class.copy.ctor "11.4.5.3 Copy/move constructors"),[[class.dtor]](class.dtor "11.4.7 Destructors"), and [[class.copy.assign]](class.copy.assign "11.4.6 Copy/move assignment operator"))[.](#12.sentence-2)

[*Example [5](#example-5)*: auto f() {struct A {}; return A{};}decltype(f()) g();auto x = g();

A program containing this translation unit is ill-formed
because g is odr-used but not defined,
and cannot be defined in any other translation unit
because the local class A cannot be named outside this
translation unit[.](#12.sentence-3)

â *end example*]

[13](#13)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L670)

A [*definition domain*](#def:definition_domain "6.3 One-definition rule [basic.def.odr]") is
a [*private-module-fragment*](module.private.frag#nt:private-module-fragment "10.5 Private module fragment [module.private.frag]") or
the portion of a translation unit
excluding its [*private-module-fragment*](module.private.frag#nt:private-module-fragment "10.5 Private module fragment [module.private.frag]") (if any)[.](#13.sentence-1)

A definition of an inline function or variable shall be reachable
from the end of every definition domain
in which it is odr-used outside of a discarded statement[.](#13.sentence-2)

[14](#14)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L679)

A definition of a class shall be reachable in every context in which
the class is used in a way that requires the class type to be complete[.](#14.sentence-1)

[*Example [6](#example-6)*:

The following complete translation unit is well-formed,
even though it never defines X:struct X; // declare X as a struct typestruct X* x1; // use X in pointer formation X* x2; // use X in pointer formation

â *end example*]

[*Note [3](#note-3)*:

The rules for declarations and expressions
describe in which contexts complete class types are required[.](#14.sentence-3)

A class
type T must be complete if

- [(14.1)](#14.1)

an object of type T is [defined](basic.def "6.2 Declarations and definitions [basic.def]"), or

- [(14.2)](#14.2)

a non-static class [data member](class.mem#def:data_member "11.4 Class members [class.mem]") of
type T is declared, or

- [(14.3)](#14.3)

T is used as the allocated type or array element type in a[*new-expression*](expr.new#nt:new-expression "7.6.2.8 New [expr.new]") ([[expr.new]](expr.new "7.6.2.8 New")), or

- [(14.4)](#14.4)

an lvalue-to-rvalue conversion is applied to
a glvalue referring
to an object of type T ([[conv.lval]](conv.lval "7.3.2 Lvalue-to-rvalue conversion")), or

- [(14.5)](#14.5)

an expression is converted (either implicitly or explicitly) to
type T ([[conv]](conv "7.3 Standard conversions"), [[expr.type.conv]](expr.type.conv "7.6.1.4 Explicit type conversion (functional notation)"), [[expr.dynamic.cast]](expr.dynamic.cast "7.6.1.7 Dynamic cast"), [[expr.static.cast]](expr.static.cast "7.6.1.9 Static cast"), [[expr.cast]](expr.cast "7.6.3 Explicit type conversion (cast notation)")), or

- [(14.6)](#14.6)

an expression that is not a null pointer constant, and has type
other than cv void*, is converted to the type pointer to T or reference to T using a standard conversion ([[conv]](conv "7.3 Standard conversions")),
a dynamic_cast ([[expr.dynamic.cast]](expr.dynamic.cast "7.6.1.7 Dynamic cast")) or
a static_cast ([[expr.static.cast]](expr.static.cast "7.6.1.9 Static cast")), or

- [(14.7)](#14.7)

a class member access operator is applied to an expression of typeT ([[expr.ref]](expr.ref "7.6.1.5 Class member access")), or

- [(14.8)](#14.8)

the typeid operator ([[expr.typeid]](expr.typeid "7.6.1.8 Type identification")) or thesizeof operator ([[expr.sizeof]](expr.sizeof "7.6.2.5 Sizeof")) is applied to an operand of
type T, or

- [(14.9)](#14.9)

a function with a return type or argument type of type T is defined ([[basic.def]](basic.def "6.2 Declarations and definitions")) or [called](expr.call "7.6.1.3 Function call [expr.call]"), or

- [(14.10)](#14.10)

a class with a base class of type T is
defined ([[class.derived]](class.derived "11.7 Derived classes")), or

- [(14.11)](#14.11)

an lvalue of type T is assigned to ([[expr.assign]](expr.assign "7.6.19 Assignment and compound assignment operators")), or

- [(14.12)](#14.12)

the type T is the subject of analignof expression ([[expr.alignof]](expr.alignof "7.6.2.6 Alignof")), or

- [(14.13)](#14.13)

an [*exception-declaration*](except.pre#nt:exception-declaration "14.1 Preamble [except.pre]") has type T, reference toT, or pointer to T ([[except.handle]](except.handle "14.4 Handling an exception"))[.](#14.sentence-4)

â *end note*]

[15](#15)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L730)

If a definable item D is defined in a translation unit
by an injected declaration X ([[expr.const]](expr.const "7.7 Constant expressions")) and
another translation unit contains a definition of D,
that definition shall be an injected declaration
having the same characteristic sequence as X;
a diagnostic is required only if D is attached to a named module and
a prior definition is reachable at the point where a later definition occurs[.](#15.sentence-1)

[16](#16)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L739)

For any other definable item D with definitions in multiple translation units,

- [(16.1)](#16.1)

if D is a non-inline non-templated function or variable, or

- [(16.2)](#16.2)

if the definitions in different translation units
do not satisfy the following requirements,

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[.](#16.sentence-1)

Given such an item,
for all definitions of D, or,
if D is an unnamed enumeration,
for all definitions of D that are reachable at any given program point,
the following requirements shall be satisfied[.](#16.sentence-2)

- [(16.3)](#16.3)

  Each such definition
shall not be attached to a named module ([[module.unit]](module.unit "10.1 Module units and purviews"))[.](#16.3.sentence-1)

- [(16.4)](#16.4)

  Each such definition shall consist of
the same sequence of tokens,
where the definition of a closure type
is considered to consist of the sequence of tokens of
the corresponding [*lambda-expression*](expr.prim.lambda.general#nt:lambda-expression "7.5.6.1 General [expr.prim.lambda.general]")[.](#16.4.sentence-1)

- [(16.5)](#16.5)

  In each such definition, corresponding names, looked up
according to [[basic.lookup]](basic.lookup "6.5 Name lookup"), shall denote the same entity, after
overload resolution ([[over.match]](over.match "12.2 Overload resolution")) and after matching of partial
template specializations ([[temp.spec.partial.match]](temp.spec.partial.match "13.7.6.2 Matching of partial specializations")), except that a name can refer to
  * [(16.5.1)](#16.5.1)

a non-volatile const object with internal or no linkage if the object
    +
          [(16.5.1.1)](#16.5.1.1)
has the same literal type in all definitions of D,

    +
          [(16.5.1.2)](#16.5.1.2)
is initialized with a [constant expression](expr.const "7.7 Constant expressions [expr.const]"),

    +
          [(16.5.1.3)](#16.5.1.3)
is not odr-used in any definition of D, and

    +
          [(16.5.1.4)](#16.5.1.4)
has the same value in all definitions of D,

or

  * [(16.5.2)](#16.5.2)

a reference with internal or no linkage
initialized with a constant expression such that
the reference refers to the same object or function in all definitions of D[.](#16.5.sentence-1)

- [(16.6)](#16.6)

  In each such definition, except within
the default arguments and default template arguments of D,
corresponding [*lambda-expression*](expr.prim.lambda.general#nt:lambda-expression "7.5.6.1 General [expr.prim.lambda.general]")*s* shall have
the same closure type (see below)[.](#16.6.sentence-1)

- [(16.7)](#16.7)

  In each such definition, corresponding entities shall have the
same language linkage[.](#16.7.sentence-1)

- [(16.8)](#16.8)

  In each such definition,
const objects with static or thread storage duration
shall be constant-initialized if
the object is constant-initialized in any such definition[.](#16.8.sentence-1)

- [(16.9)](#16.9)

  In each such definition,
corresponding manifestly constant-evaluated expressions
that are not value-dependent
shall have the same value ([[expr.const]](expr.const "7.7 Constant expressions"), [[temp.dep.constexpr]](temp.dep.constexpr "13.8.3.4 Value-dependent expressions"))[.](#16.9.sentence-1)

- [(16.10)](#16.10)

  In each such definition, the overloaded operators referred
to, the implicit calls to conversion functions, constructors, operator
new functions and operator delete functions, shall refer to the same
function[.](#16.10.sentence-1)

- [(16.11)](#16.11)

  In each such definition,
a default argument used by an (implicit or explicit) function call or
a default template argument used by an (implicit or explicit)[*template-id*](temp.names#nt:template-id "13.3 Names of template specializations [temp.names]"),[*simple-template-id*](temp.names#nt:simple-template-id "13.3 Names of template specializations [temp.names]"), or[*splice-specialization-specifier*](basic.splice#nt:splice-specialization-specifier "6.6 Splice specifiers [basic.splice]") is treated as if its token sequence
were present in the definition of D;
that is, the default argument or default template argument
is subject to the requirements described in this paragraph (recursively)[.](#16.11.sentence-1)

- [(16.12)](#16.12)

  In each such definition,
corresponding [*reflect-expression*](expr.reflect#nt:reflect-expression "7.6.2.10 The reflection operator [expr.reflect]")*s* ([[expr.reflect]](expr.reflect "7.6.2.10 The reflection operator"))
compute equivalent values ([[expr.eq]](expr.eq "7.6.10 Equality operators"))[.](#16.12.sentence-1)

[17](#17)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L824)

For the purposes of the preceding requirements:

- [(17.1)](#17.1)

  If D is a class with an implicitly-declared
constructor ([[class.default.ctor]](class.default.ctor "11.4.5.2 Default constructors"), [[class.copy.ctor]](class.copy.ctor "11.4.5.3 Copy/move constructors")),
it is as if the constructor was
implicitly defined in every translation unit where it is odr-used, and the
implicit definition in every translation unit shall call the same
constructor for a subobject of D[.](#17.1.sentence-1)
  [*Example [7](#example-7)*: // translation unit 1:struct X { X(int, int);
 X(int, int, int);};
X::X(int, int = 0) { }class D { X x = 0;};
D d1; // X(int, int) called by D()// translation unit 2:struct X { X(int, int);
 X(int, int, int);};
X::X(int, int = 0, int = 0) { }class D { X x = 0;};
D d2; // X(int, int, int) called by D();// D()'s implicit definition violates the ODR â *end example*]

- [(17.2)](#17.2)

  If D is a class with
a defaulted three-way comparison operator function ([[class.spaceship]](class.spaceship "11.10.3 Three-way comparison")),
it is as if the operator was
implicitly defined in every translation unit where it is odr-used, and the
implicit definition in every translation unit shall call the same
comparison operators for each subobject of D[.](#17.2.sentence-1)

- [(17.3)](#17.3)

  If D is a template and is defined in more than one
translation unit, the requirements
apply both to names from the template's enclosing scope used in the
template definition, and also to dependent names at
the point of instantiation ([[temp.dep]](temp.dep "13.8.3 Dependent names"))[.](#17.3.sentence-1)

[18](#18)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L875)

These requirements also apply to corresponding entities
defined within each definition of D (including the closure types of [*lambda-expression*](expr.prim.lambda.general#nt:lambda-expression "7.5.6.1 General [expr.prim.lambda.general]")*s*,
but excluding entities defined within default arguments or
default template arguments of either D or
an entity not defined within D)[.](#18.sentence-1)

For each such entity and for D itself,
the behavior is as if there is a single entity with a single definition,
including in the application of these requirements to other entities[.](#18.sentence-2)

[*Note [4](#note-4)*:

The entity is still declared in multiple translation units, and [[basic.link]](basic.link "6.7 Program and linkage") still applies to these declarations[.](#18.sentence-3)

In particular,[*lambda-expression*](expr.prim.lambda.general#nt:lambda-expression "7.5.6.1 General [expr.prim.lambda.general]")*s* ([[expr.prim.lambda]](expr.prim.lambda "7.5.6 Lambda expressions"))
appearing in the type of D can result
in the different declarations having distinct types, and[*lambda-expression*](expr.prim.lambda.general#nt:lambda-expression "7.5.6.1 General [expr.prim.lambda.general]")*s* appearing in a default argument of D might still denote different types in different translation units[.](#18.sentence-4)

â *end note*]

[19](#19)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L895)

[*Example [8](#example-8)*: inline void f(bool cond, void (*p)()) {if (cond) f(false, []{});}inline void g(bool cond, void (*p)() = []{}) {if (cond) g(false);}struct X {void h(bool cond, void (*p)() = []{}) {if (cond) h(false); }};

If the definition of f appears in multiple translation units,
the behavior of the program is as if
there is only one definition of f[.](#19.sentence-1)

If the definition of g appears in multiple translation units,
the program is ill-formed (no diagnostic required) because
each such definition uses a default argument that
refers to a distinct [*lambda-expression*](expr.prim.lambda.general#nt:lambda-expression "7.5.6.1 General [expr.prim.lambda.general]") closure type[.](#19.sentence-2)

The definition of X can appear
in multiple translation units of a valid program;
the [*lambda-expression*](expr.prim.lambda.general#nt:lambda-expression "7.5.6.1 General [expr.prim.lambda.general]")*s* defined within
the default argument of X​::​h within the definition of X denote the same closure type in each translation unit[.](#19.sentence-3)

â *end example*]

[20](#20)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L925)

If, at any point in the program,
there is more than one
reachable unnamed enumeration definition in the same scope
that have the same first enumerator name and
do not have typedef names for linkage purposes ([[dcl.enum]](dcl.enum "9.8.1 Enumeration declarations")),
those unnamed enumeration types shall be the same; no diagnostic required[.](#20.sentence-1)

[16)](#footnote-16)[16)](#footnoteref-16)

An implementation is not required
to call allocation and
deallocation functions from constructors or destructors; however, this
is a permissible implementation technique[.](#footnote-16.sentence-1)
