tmp/tmpovgyinle/{from.md → to.md}
RENAMED
|
@@ -2,47 +2,81 @@
|
|
| 2 |
|
| 3 |
No translation unit shall contain more than one definition of any
|
| 4 |
variable, function, class type, enumeration type, or template.
|
| 5 |
|
| 6 |
An expression is *potentially evaluated* unless it is an unevaluated
|
| 7 |
-
operand (Clause [[expr]]) or a subexpression thereof.
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
is odr-used by
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
Every program shall contain exactly one definition of every non-inline
|
| 46 |
function or variable that is odr-used in that program; no diagnostic
|
| 47 |
required. The definition can appear explicitly in the program, it can be
|
| 48 |
found in the standard or a user-defined library, or (when appropriate)
|
|
@@ -73,12 +107,12 @@ complete class types are required. A class type `T` must be complete if:
|
|
| 73 |
object of type `T` ([[conv.lval]]), or
|
| 74 |
- an expression is converted (either implicitly or explicitly) to type
|
| 75 |
`T` (Clause [[conv]], [[expr.type.conv]], [[expr.dynamic.cast]],
|
| 76 |
[[expr.static.cast]], [[expr.cast]]), or
|
| 77 |
- an expression that is not a null pointer constant, and has type other
|
| 78 |
-
than `void*`, is converted to the type pointer to `T` or
|
| 79 |
-
`T` using
|
| 80 |
`dynamic_cast` ([[expr.dynamic.cast]]) or a `static_cast` (
|
| 81 |
[[expr.static.cast]]), or
|
| 82 |
- a class member access operator is applied to an expression of type
|
| 83 |
`T` ([[expr.ref]]), or
|
| 84 |
- the `typeid` operator ([[expr.typeid]]) or the `sizeof` operator (
|
|
@@ -110,15 +144,15 @@ unit, then
|
|
| 110 |
- in each definition of `D`, corresponding names, looked up according
|
| 111 |
to [[basic.lookup]], shall refer to an entity defined within the
|
| 112 |
definition of `D`, or shall refer to the same entity, after overload
|
| 113 |
resolution ([[over.match]]) and after matching of partial template
|
| 114 |
specialization ([[temp.over]]), except that a name can refer to a
|
| 115 |
-
`const` object with internal or no linkage if the object
|
| 116 |
-
literal type in all definitions of `D`, and the object is
|
| 117 |
-
with a constant expression ([[expr.const]]), and the
|
| 118 |
-
|
| 119 |
-
|
| 120 |
- in each definition of `D`, corresponding entities shall have the same
|
| 121 |
language linkage; and
|
| 122 |
- in each definition of `D`, the overloaded operators referred to, the
|
| 123 |
implicit calls to conversion functions, constructors, operator new
|
| 124 |
functions and operator delete functions, shall refer to the same
|
|
@@ -158,9 +192,9 @@ unit, then
|
|
| 158 |
If `D` is a template and is defined in more than one translation unit,
|
| 159 |
then the preceding requirements shall apply both to names from the
|
| 160 |
template’s enclosing scope used in the template definition (
|
| 161 |
[[temp.nondep]]), and also to dependent names at the point of
|
| 162 |
instantiation ([[temp.dep]]). If the definitions of `D` satisfy all
|
| 163 |
-
these requirements, then the
|
| 164 |
-
|
| 165 |
requirements, then the behavior is undefined.
|
| 166 |
|
|
|
|
| 2 |
|
| 3 |
No translation unit shall contain more than one definition of any
|
| 4 |
variable, function, class type, enumeration type, or template.
|
| 5 |
|
| 6 |
An expression is *potentially evaluated* unless it is an unevaluated
|
| 7 |
+
operand (Clause [[expr]]) or a subexpression thereof. The set of
|
| 8 |
+
*potential results* of an expression `e` is defined as follows:
|
| 9 |
+
|
| 10 |
+
- If `e` is an *id-expression* ([[expr.prim.general]]), the set
|
| 11 |
+
contains only `e`.
|
| 12 |
+
- If `e` is a class member access expression ([[expr.ref]]), the set
|
| 13 |
+
contains the potential results of the object expression.
|
| 14 |
+
- If `e` is a pointer-to-member expression ([[expr.mptr.oper]]) whose
|
| 15 |
+
second operand is a constant expression, the set contains the
|
| 16 |
+
potential results of the object expression.
|
| 17 |
+
- If `e` has the form `(e1)`, the set contains the potential results of
|
| 18 |
+
`e1`.
|
| 19 |
+
- If `e` is a glvalue conditional expression ([[expr.cond]]), the set
|
| 20 |
+
is the union of the sets of potential results of the second and third
|
| 21 |
+
operands.
|
| 22 |
+
- If `e` is a comma expression ([[expr.comma]]), the set contains the
|
| 23 |
+
potential results of the right operand.
|
| 24 |
+
- Otherwise, the set is empty.
|
| 25 |
+
|
| 26 |
+
This set is a (possibly-empty) set of *id-expression*s, each of which is
|
| 27 |
+
either `e` or a subexpression of `e`. In the following example, the set
|
| 28 |
+
of potential results of the initializer of `n` contains the first `S::x`
|
| 29 |
+
subexpression, but not the second `S::x` subexpression.
|
| 30 |
+
|
| 31 |
+
``` cpp
|
| 32 |
+
struct S { static const int x = 0; };
|
| 33 |
+
const int &f(const int &r);
|
| 34 |
+
int n = b ? (1, S::x) // S::x is not odr-used here
|
| 35 |
+
: f(S::x); // S::x is odr-used here, so
|
| 36 |
+
// a definition is required
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
A variable `x` whose name appears as a potentially-evaluated expression
|
| 40 |
+
`ex` is *odr-used* by `ex` unless applying the lvalue-to-rvalue
|
| 41 |
+
conversion ([[conv.lval]]) to `x` yields a constant expression (
|
| 42 |
+
[[expr.const]]) that does not invoke any non-trivial functions and, if
|
| 43 |
+
`x` is an object, `ex` is an element of the set of potential results of
|
| 44 |
+
an expression `e`, where either the lvalue-to-rvalue conversion (
|
| 45 |
+
[[conv.lval]]) is applied to `e`, or `e` is a discarded-value
|
| 46 |
+
expression (Clause [[expr]]). `this` is odr-used if it appears as a
|
| 47 |
+
potentially-evaluated expression (including as the result of the
|
| 48 |
+
implicit transformation in the body of a non-static member function (
|
| 49 |
+
[[class.mfct.non-static]])). A virtual member function is odr-used if it
|
| 50 |
+
is not pure. A function whose name appears as a potentially-evaluated
|
| 51 |
+
expression is odr-used if it is the unique lookup result or the selected
|
| 52 |
+
member of a set of overloaded functions ([[basic.lookup]],
|
| 53 |
+
[[over.match]], [[over.over]]), unless it is a pure virtual function and
|
| 54 |
+
its name is not explicitly qualified. This covers calls to named
|
| 55 |
+
functions ([[expr.call]]), operator overloading (Clause [[over]]),
|
| 56 |
+
user-defined conversions ([[class.conv.fct]]), allocation function for
|
| 57 |
+
placement new ([[expr.new]]), as well as non-default initialization (
|
| 58 |
+
[[dcl.init]]). A constructor selected to copy or move an object of class
|
| 59 |
+
type is odr-used even if the call is actually elided by the
|
| 60 |
+
implementation ([[class.copy]]). An allocation or deallocation function
|
| 61 |
+
for a class is odr-used by a new expression appearing in a
|
| 62 |
+
potentially-evaluated expression as specified in [[expr.new]] and
|
| 63 |
+
[[class.free]]. A deallocation function for a class is odr-used by a
|
| 64 |
+
delete expression appearing in a potentially-evaluated expression as
|
| 65 |
+
specified in [[expr.delete]] and [[class.free]]. A non-placement
|
| 66 |
+
allocation or deallocation function for a class is odr-used by the
|
| 67 |
+
definition of a constructor of that class. A non-placement deallocation
|
| 68 |
+
function for a class is odr-used by the definition of the destructor of
|
| 69 |
+
that class, or by being selected by the lookup at the point of
|
| 70 |
+
definition of a virtual destructor ([[class.dtor]]).[^2] An assignment
|
| 71 |
+
operator function in a class is odr-used by an implicitly-defined
|
| 72 |
+
copy-assignment or move-assignment function for another class as
|
| 73 |
+
specified in [[class.copy]]. A default constructor for a class is
|
| 74 |
+
odr-used by default initialization or value initialization as specified
|
| 75 |
+
in [[dcl.init]]. A constructor for a class is odr-used as specified in
|
| 76 |
+
[[dcl.init]]. A destructor for a class is odr-used if it is potentially
|
| 77 |
+
invoked ([[class.dtor]]).
|
| 78 |
|
| 79 |
Every program shall contain exactly one definition of every non-inline
|
| 80 |
function or variable that is odr-used in that program; no diagnostic
|
| 81 |
required. The definition can appear explicitly in the program, it can be
|
| 82 |
found in the standard or a user-defined library, or (when appropriate)
|
|
|
|
| 107 |
object of type `T` ([[conv.lval]]), or
|
| 108 |
- an expression is converted (either implicitly or explicitly) to type
|
| 109 |
`T` (Clause [[conv]], [[expr.type.conv]], [[expr.dynamic.cast]],
|
| 110 |
[[expr.static.cast]], [[expr.cast]]), or
|
| 111 |
- an expression that is not a null pointer constant, and has type other
|
| 112 |
+
than *cv* `void*`, is converted to the type pointer to `T` or
|
| 113 |
+
reference to `T` using a standard conversion (Clause [[conv]]), a
|
| 114 |
`dynamic_cast` ([[expr.dynamic.cast]]) or a `static_cast` (
|
| 115 |
[[expr.static.cast]]), or
|
| 116 |
- a class member access operator is applied to an expression of type
|
| 117 |
`T` ([[expr.ref]]), or
|
| 118 |
- the `typeid` operator ([[expr.typeid]]) or the `sizeof` operator (
|
|
|
|
| 144 |
- in each definition of `D`, corresponding names, looked up according
|
| 145 |
to [[basic.lookup]], shall refer to an entity defined within the
|
| 146 |
definition of `D`, or shall refer to the same entity, after overload
|
| 147 |
resolution ([[over.match]]) and after matching of partial template
|
| 148 |
specialization ([[temp.over]]), except that a name can refer to a
|
| 149 |
+
non-volatile `const` object with internal or no linkage if the object
|
| 150 |
+
has the same literal type in all definitions of `D`, and the object is
|
| 151 |
+
initialized with a constant expression ([[expr.const]]), and the
|
| 152 |
+
object is not odr-used, and the object has the same value in all
|
| 153 |
+
definitions of `D`; and
|
| 154 |
- in each definition of `D`, corresponding entities shall have the same
|
| 155 |
language linkage; and
|
| 156 |
- in each definition of `D`, the overloaded operators referred to, the
|
| 157 |
implicit calls to conversion functions, constructors, operator new
|
| 158 |
functions and operator delete functions, shall refer to the same
|
|
|
|
| 192 |
If `D` is a template and is defined in more than one translation unit,
|
| 193 |
then the preceding requirements shall apply both to names from the
|
| 194 |
template’s enclosing scope used in the template definition (
|
| 195 |
[[temp.nondep]]), and also to dependent names at the point of
|
| 196 |
instantiation ([[temp.dep]]). If the definitions of `D` satisfy all
|
| 197 |
+
these requirements, then the behavior is as if there were a single
|
| 198 |
+
definition of `D`. If the definitions of `D` do not satisfy these
|
| 199 |
requirements, then the behavior is undefined.
|
| 200 |
|