cpp/language/tu local

Translation-unit-local (TU-local) entities are introduced to prevent entities that are supposed to be local (not used in any other translation unit) being exposed and used in other translation units.

An example from Understanding C++ Modules: Part 2 illustrates the problem of not constraining exposures:

TU-local entities
An entity is TU-local if it is
 * 1) a type, function, variable, or template that
 * 2) has a name with, or
 * 3) does not have a name with linkage and is declared, or introduced by a, within the definition of a TU-local entity,
 * 4) a type with no name that is defined outside a, function body, or initializer or is introduced by a defining-type-specifier (type-specifier, class-specifier or enum-specifier) that is used to declare only TU-local entities,
 * 5) a specialization of a TU-local template,
 * 6) a specialization of a template with any TU-local template argument, or
 * 7) a specialization of a template whose (possibly instantiated) declaration is an exposure (defined below).

A value or object is TU-local if either
 * 1) it is, or is a pointer to, a TU-local function or the object associated with a TU-local variable, or
 * 2) it is an object of class or array type and any of its  or any of the objects or functions to which its non-static data members of reference type refer is TU-local and is.

Exposures
A declaration D names an entity E if
 * 1) D contains a lambda expression whose closure type is E,
 * 2) E is not a function or function template and D contains an id-expression, type-specifier, nested-name-specifier, template-name, or concept-name denoting E, or
 * 3) E is a function or function template and D contains an expression that names E or an id-expression that refers to a set of overloads that contains E.

A declaration is an exposure if it either names a TU-local entity, ignoring or defines a constexpr variable initialized to a TU-local value.
 * 1) the function-body for a non-inline function or function template (but not the deduced return type for a (possibly instantiated) definition of a function with a declared return type that uses a ),
 * 2) the initializer for a variable or variable template (but not the variable’s type),
 * 3) friend declarations in a class definition, and
 * 4) any reference to a non-volatile const object or reference with internal or no linkage initialized with a constant expression that is not an ,

TU-local constraints
If a (possibly instantiated) of, or a  for, a non-TU-local entity in a  (outside the private-module-fragment, if any) or module partition is an exposure, the program is ill-formed. Such a declaration in any other context is deprecated.

If a declaration that appears in one translation unit names a TU-local entity declared in another translation unit that is not a header unit, the program is ill-formed. A declaration instantiated for a template specialization appears at the point of instantiation of the specialization.

Example
Translation unit #1:

Translation unit #2: