Talk:cpp/language/inline
The rule for the global module of C++20 does not look specific to C++20 because there is not a box around it all. I feel it should be below the rules for C++11 and C++17 too.
- There are boxes everywhere https://puu.sh/Jcor6/4be9b1f308.png --Ybab321 (talk) 00:06, 22 July 2022 (PDT)
Mismatch between rules surrounding static locals: Currently, this page states in regards to inline functions with external linkage, they must have a common definition, however, this requirement does not exist for functions with internal linkage. On the other hand, it describes static locals *all* inline functions as referring to a common variable across definitions:
An inline function or inline variable (since C++17) has the following properties: ... An inline function or variable (since C++17) with external linkage ... There may be more than one definition of an inline function or variable (since C++17) in the program as long as each definition appears in a different translation unit and (for non-static inline functions and variables (since C++17)) all definitions are identical. ...
Later, outside the section for external linkage:
In an inline function, Function-local static objects in all function definitions are shared across all translation units (they all refer to the same object defined in one translation unit).
On the other hand, the page for storage class and linkage does limit this requirement to external linkage inline functions: https://en.cppreference.com/w/cpp/language/storage_duration#Static_local_variables :
Function-local static objects in all definitions of the same inline function (which may be implicitly inline) all refer to the same object defined in one translation unit, as long as the function has external linkage.
I would suggest to either move the section regarding static locals on this page to the list of characteristics of external function, to reflect that static locals are not shared across definitions for inline functions with internal linkage; or to add the same qualification as the storage duration/linkage page, i.e. change wording to
Function-local static objects in all function definitions are shared across all translation units (they all refer to the same object defined in one translation unit), as long as the function has external linkage.