diff --git a/source/basic.tex b/source/basic.tex index 62ae3796ac..c29160b2ac 100644 --- a/source/basic.tex +++ b/source/basic.tex @@ -774,34 +774,74 @@ \pnum \begin{example} +\begin{codeblock} +static int local = 0; +inline int a(int = local) { + return 0; +} +inline int b = a(0); +\end{codeblock} +If the definition of \tcode{a} or \tcode{b} appears in multiple translation units, +the behavior of the program is as if +there is only one definition of \tcode{a} or \tcode{b}, respectively. + +\begin{codeblock} +inline int c = a(); +\end{codeblock} +If the definition of \tcode{c} appears in multiple translation units, +the program is ill-formed (no diagnostic required) because +each such definition calls \tcode{a} with a different function argument. + \begin{codeblock} inline void f(bool cond, void (*p)()) { if (cond) f(false, []{}); } +\end{codeblock} +If the definition of \tcode{f} appears in multiple translation units, +the behavior of the program is as if +there is only one definition of \tcode{f}. + +\begin{codeblock} inline void g(bool cond, void (*p)() = []{}) { if (cond) g(false); } +\end{codeblock} +If the definition of \tcode{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 \grammarterm{lambda-expression} closure type. + +\begin{codeblock} struct X { void h(bool cond, void (*p)() = []{}) { if (cond) h(false); } }; \end{codeblock} - -If the definition of \tcode{f} appears in multiple translation units, -the behavior of the program is as if -there is only one definition of \tcode{f}. -If the definition of \tcode{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 \grammarterm{lambda-expression} closure type. The definition of \tcode{X} can appear in multiple translation units of a valid program; the \grammarterm{lambda-expression}{s} defined within the default argument of \tcode{X::h} within the definition of \tcode{X} denote the same closure type in each translation unit. + +\begin{codeblock} +inline decltype([]{}) u = {}; +\end{codeblock} +If the declaration of \tcode{u} appears in multiple translation units, +the program is ill-formed (no diagnostic required) because each such declaration +declares an object of distinct type. + +\begin{codeblock} +inline auto v = []{}; +inline auto w = decltype([]{}){}; +\end{codeblock} +If the definition of \tcode{v} or \tcode{w} appears in multiple translation units, +the behavior is as if there is only one definition of \tcode{v} or \tcode{w} +because the definition of its closure type is considered to be part of the +token sequence of the definition of \tcode{v} or \tcode{w} respectively. \end{example} + \pnum If, at any point in the program, there is more than one