This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-12-19


2670. Programs and translation units

Section: 6.6  [basic.link]     Status: open     Submitter: Gabriel dos Reis     Date: 2022-12-21

Subclause 6.6 [basic.link] paragraph 1 specifies:

A program consists of one or more translation units (5.1 [lex.separate]) linked together. A translation unit consists of a sequence of declarations.

Subclause 5.1 [lex.separate] paragraph 1 defines "translation unit":

A source file together with all the headers (16.4.2.3 [headers]) and source files included (15.3 [cpp.include]) via the preprocessing directive #include, less any source lines skipped by any of the conditional inclusion (15.2 [cpp.cond]) preprocessing directives, is called a translation unit.

Subclause 5.2 [lex.phases] paragraph 7 first mentions the "translation" of translation units:

Whitespace characters separating tokens are no longer significant. Each preprocessing token is converted into a token (5.10 [lex.token]). The resulting tokens are syntactically and semantically analyzed and translated as a translation unit.

However, 5.2 [lex.phases] paragraph 8 introduces "instantiation units" and 5.2 [lex.phases] paragraph 9 specifies:

Translated translation units and instantiation units are combined as follows:

and 5.2 [lex.phases] paragraph 9 specifies:

All external entity references are resolved. Library components are linked to satisfy external references to entities not defined in the current translation. All such translator output is collected into a program image which contains information needed for execution in its execution environment.

The term "linking" in 5.2 [lex.phases] comes after translated translation units and instantiation units are combined, yet 6.6 [basic.link] paragraph 1 states that (untranslated) translation units are linked to form a program. That seems inconsistent.

Additional notes (February, 2023)

See also issue 2518, which introduced the term "preprocessing translation unit" to remove the conflict between 6.6 [basic.link] paragraph 1 and 5.1 [lex.separate] paragraph 1.