Title
Programs and translation units
Status
open
Section
6.6 [basic.link]
Submitter
Gabriel dos Reis

Created on 2022-12-21.00:00:00 last changed 14 months ago

Messages

Date: 2023-02-15.00:00:00

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.

Date: 2022-12-21.00:00:00

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.6 [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.

History
Date User Action Args
2023-02-18 23:48:04adminsetmessages: + msg7205
2022-12-21 00:00:00admincreate