|
614 | 614 | \pnum |
615 | 615 | Every program shall contain at least one definition of every |
616 | 616 | function or variable that is odr-used in that program |
617 | | -outside of a discarded statement\iref{stmt.if}; no diagnostic required. |
| 617 | +outside of a discarded statement\iref{stmt.if}; no diagnostic required\ifndrdef{basic.def.odr.exact.one.def}. |
618 | 618 | The definition can appear explicitly in the program, it can be found in |
619 | 619 | the standard or a user-defined library, or (when appropriate) it is |
620 | 620 | implicitly defined (see~\ref{class.default.ctor}, \ref{class.copy.ctor}, |
|
882 | 882 | reachable unnamed enumeration definition in the same scope |
883 | 883 | that have the same first enumerator name and |
884 | 884 | do not have typedef names for linkage purposes\iref{dcl.enum}, |
885 | | -those unnamed enumeration types shall be the same; no diagnostic required. |
| 885 | +those unnamed enumeration types shall be the same; no diagnostic required\ifndrdef{basic.def.odr.unnamed.enum.same.type}. |
886 | 886 | \indextext{one-definition rule|)} |
887 | 887 |
|
888 | 888 | \rSec1[basic.scope]{Scope}% |
|
1751 | 1751 | If it is an invalid set, the program is ill-formed. |
1752 | 1752 | If it differs from the result of a search in $T$ for $M$ |
1753 | 1753 | in a complete-class context\iref{class.mem} of $T$, |
1754 | | -the program is ill-formed, no diagnostic required. |
| 1754 | +the program is ill-formed, no diagnostic required\ifndrdef{class.member.lookup.name.refers.diff.decl}. |
1755 | 1755 | \begin{example} |
1756 | 1756 | \begin{codeblock} |
1757 | 1757 | struct A { int x; }; // S(x,A) = \{ \{ \tcode{A::x} \}, \{ \tcode{A} \} \} |
|
3486 | 3486 | zero or more objects of implicit-lifetime types\iref{term.implicit.lifetime.type} |
3487 | 3487 | in its specified region of storage |
3488 | 3488 | if doing so would result in the program having defined behavior. |
3489 | | -If no such set of objects would give the program defined behavior, |
| 3489 | +If no such set of objects would give the program defined behavior\ubdef{intro.object.implicit.create}, |
3490 | 3490 | the behavior of the program is undefined. |
3491 | 3491 | If multiple such sets of objects would give the program defined behavior, |
3492 | 3492 | it is unspecified which such set of objects is created. |
|
3748 | 3748 | if the pointer were of type \tcode{\keyword{void}*} is |
3749 | 3749 | well-defined. Indirection through such a pointer is permitted but the resulting lvalue may only be used in |
3750 | 3750 | limited ways, as described below. The |
3751 | | -program has undefined behavior if |
| 3751 | +program has undefined behavior\ubdef{lifetime.outside.pointer} if: |
3752 | 3752 | \begin{itemize} |
3753 | 3753 | \item |
3754 | 3754 | the pointer is used as the operand of a \grammarterm{delete-expression}, |
|
3811 | 3811 | a glvalue refers to |
3812 | 3812 | allocated storage\iref{basic.stc.dynamic.allocation}, and using the |
3813 | 3813 | properties of the glvalue that do not depend on its value is |
3814 | | -well-defined. The program has undefined behavior if |
| 3814 | +well-defined. The program has undefined behavior\ubdef{lifetime.outside.glvalue} if: |
3815 | 3815 | \begin{itemize} |
3816 | 3816 | \item the glvalue is used to access the object, or |
3817 | 3817 | \item the glvalue is used to call a non-static member function of the object, or |
|
3901 | 3901 | \end{footnote} |
3902 | 3902 | and another object of the original type does not occupy |
3903 | 3903 | that same storage location when the implicit destructor call takes |
3904 | | -place, the behavior of the program is undefined. This is true |
| 3904 | +place, the behavior of the program is undefined\ubdef{original.type.implicit.destructor}. This is true |
3905 | 3905 | even if the block is exited with an exception. |
3906 | 3906 | \begin{example} |
3907 | 3907 | \begin{codeblock} |
|
3921 | 3921 | Creating a new object within the storage that a const, complete |
3922 | 3922 | object with static, thread, or automatic storage duration occupies, |
3923 | 3923 | or within the storage that such a const object used to occupy before |
3924 | | -its lifetime ended, results in undefined behavior. |
| 3924 | +its lifetime ended, results in undefined behavior\ubdef{creating.within.const.complete.obj}. |
3925 | 3925 | \begin{example} |
3926 | 3926 | \begin{codeblock} |
3927 | 3927 | struct B { |
|
4260 | 4260 | does not satisfy the semantic constraints |
4261 | 4261 | specified in~\ref{basic.stc.dynamic.allocation} |
4262 | 4262 | and~\ref{basic.stc.dynamic.deallocation}, |
4263 | | -the behavior is undefined. |
| 4263 | +the behavior is undefined\ubdef{basic.stc.alloc.dealloc.constraint}. |
4264 | 4264 |
|
4265 | 4265 | \indextext{storage duration!dynamic|)} |
4266 | 4266 |
|
|
6152 | 6152 | The value computations of the operands of an |
6153 | 6153 | operator are sequenced before the value computation of the result of the |
6154 | 6154 | operator. |
6155 | | -The behavior is undefined if |
| 6155 | +The behavior is undefined\iref{intro.multithread}\ubdef{intro.execution.unsequenced.modification} if |
6156 | 6156 | \begin{itemize} |
6157 | 6157 | \item |
6158 | 6158 | \indextext{side effects}% |
|
6552 | 6552 | and neither happens before the other, |
6553 | 6553 | except for the special case for signal handlers described below. |
6554 | 6554 | Any such data race results in undefined |
6555 | | -behavior. |
| 6555 | +behavior\ubdef{intro.races.data}. |
6556 | 6556 | \begin{note} |
6557 | 6557 | It can be shown that programs that correctly use mutexes |
6558 | 6558 | and \tcode{memory_order::seq_cst} operations to prevent all data races and use no |
|
6916 | 6916 | objects with automatic storage duration\iref{class.dtor}. If |
6917 | 6917 | \tcode{std::exit} is invoked during the destruction of |
6918 | 6918 | an object with static or thread storage duration, the program has undefined |
6919 | | -behavior. |
| 6919 | +behavior\ubdef{basic.start.main.exit.during.destruction}. |
6920 | 6920 |
|
6921 | 6921 | \pnum |
6922 | 6922 | \indextext{termination!program}% |
|
7210 | 7210 | \pnum |
7211 | 7211 | If a function contains a block variable of static or thread storage duration that has been |
7212 | 7212 | destroyed and the function is called during the destruction of an object with static or |
7213 | | -thread storage duration, the program has undefined behavior if the flow of control |
| 7213 | +thread storage duration, the program has undefined behavior\ubdef{basic.start.term.use.after.destruction} if the flow of control |
7214 | 7214 | passes through the definition of the previously destroyed block variable. |
7215 | 7215 | \begin{note} |
7216 | 7216 | Likewise, the behavior is undefined |
|
7237 | 7237 | handlers\iref{support.runtime} that does not happen before\iref{intro.multithread} |
7238 | 7238 | completion of destruction of objects with static storage duration and execution of |
7239 | 7239 | \tcode{std::atexit} registered functions\iref{support.start.term}, the program has |
7240 | | -undefined behavior. |
| 7240 | +undefined behavior\ubdef{basic.start.term.signal.handler}. |
7241 | 7241 | \begin{note} |
7242 | 7242 | If there is a use of an object with static storage |
7243 | 7243 | duration that does not happen before the object's destruction, the program has undefined |
|
0 commit comments