You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -130,13 +131,13 @@ An <DocLink dest="/cpp/language/declarations/asm">asm declaration</DocLink> does
130
131
131
132
Where necessary, the compiler may implicitly define the <DocLink dest="/cpp/language/classes/default_constructor">default constructor</DocLink>, <DocLink dest="/cpp/language/classes/copy_constructor">copy constructor</DocLink>, <DocLink dest="/cpp/language/classes/move_constructor">move constructor</DocLink>, <DocLink dest="/cpp/language/classes/as_operator">copy assignment operator</DocLink>, <DocLink dest="/cpp/language/classes/move_operator">move assignment operator</DocLink>, and the <DocLink dest="/cpp/language/classes/destructor">destructor</DocLink>.
132
133
133
-
If the definition of any object results in an object of <DocLink dest="/cpp/language/basic_concepts/incomplete_type">incomplete type</DocLink> or <DocLink dest="/cpp/language/classes/abstract_class">abstract class type</DocLink>, the program is ill-formed.
134
+
If the definition of any object results in an object of <DocLink dest="/cpp/language/basic_concepts/incomplete_type">incomplete type</DocLink> or <DocLink dest="/cpp/language/classes/abstract_class">abstract class type</DocLink>, the program is <Behavior kind="ill-formed">ill-formed</Behavior>.
134
135
135
136
## One Definition Rule
136
137
137
138
Only one definition of any variable, function, class type, enumeration type<Revision since="C++20">, <DocLink dest="/cpp/language/templates/constraints">concept</DocLink></Revision> or template is allowed in any one translation unit (some of these may have multiple declarations, but only one definition is allowed).
138
139
139
-
One and only one definition of every non-<DocLink dest="/cpp/language/declarations/inline">inline</DocLink> function or variable that is _odr-used_ (see below) is required to appear in the entire program (including any standard and user-defined libraries). The compiler is not required to diagnose this violation, but the behavior of the program that violates it is undefined.
140
+
One and only one definition of every non-<DocLink dest="/cpp/language/declarations/inline">inline</DocLink> function or variable that is _odr-used_ (see below) is required to appear in the entire program (including any standard and user-defined libraries). The compiler is not required to diagnose this violation, but the behavior of the program that violates it is <Behavior kind="undef">undefined</Behavior>.
140
141
141
142
For an inline function<Revision since="C++17"> or inline variable</Revision>, a definition is required in every translation unit where it is _odr-used_.
142
143
@@ -170,9 +171,9 @@ There can be more than one definition in a program of each of the following: cla
170
171
171
172
- If the definition is for a template, then all these requirements apply to both names at the point of definition and dependent names at the point of instantiation.
172
173
173
-
If all these requirements are satisfied, the program behaves as if there is only one definition in the entire program. Otherwise, the program is ill-formed, no diagnostic required.
174
+
If all these requirements are satisfied, the program behaves as if there is only one definition in the entire program. Otherwise, the program is <Behavior kind="ifndr">ill-formed, no diagnostic required</Behavior>.
174
175
175
-
Note: in C, there is no program-wide ODR for types, and even extern declarations of the same variable in different translation units may have different types <DocLink dest="/c/language/basic_concepts/compatible_type" section="compatible-types">as long as they are compatible</DocLink>. In C++, the source-code tokens used in declarations of the same type must be the same as described above: if one .cpp file defines `structS { int x; };` and the other .cpp file defines `structS { int y; }`;, the behavior of the program that links them together is undefined. This is usually resolved with <DocLink dest="/cpp/language/declarations/namespace">unnamed namespaces</DocLink>.
176
+
Note: in C, there is no program-wide ODR for types, and even extern declarations of the same variable in different translation units may have different types <DocLink dest="/c/language/basic_concepts/compatible_type" section="compatible-types">as long as they are compatible</DocLink>. In C++, the source-code tokens used in declarations of the same type must be the same as described above: if one .cpp file defines `structS { int x; };` and the other .cpp file defines `structS { int y; }`;, the behavior of the program that links them together is <Behavior kind="undef">undefined</Behavior>. This is usually resolved with <DocLink dest="/cpp/language/declarations/namespace">unnamed namespaces</DocLink>.
0 commit comments