This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of WP status.
Section: 31.4.2 [iostream.objects.overview] Status: WP Submitter: Tim Song Opened: 2023-02-09 Last modified: 2023-02-13
Priority: Not Prioritized
View all other issues in [iostream.objects.overview].
View all issues with WP status.
Discussion:
In the old world, #include <iostream> behaves as if it defined a static-storage-duration ios_base::Init object, which causes the standard iostreams objects to be initialized (if necessary) on startup and flushed on shutdown.
But we don't include headers with import std;, so we need separate wording to provide this guarantee. The proposed resolution below was adapted from a suggestion by Mathias Stearn on the reflector.[2023-02-09 Tim updates wording following LWG discussion]
[Issaquah 2023-02-09; LWG]
Move to Immediate for C++23
[2023-02-13 Status changed: Immediate → WP.]
Proposed resolution:
This wording is relative to N4928.
Modify 31.4.2 [iostream.objects.overview]p5 as indicated:
-5- The results of including <iostream> in a translation unit shall be as if <iostream> defined an instance of ios_base::Init with static storage duration. Each C++ library module (16.4.2.4 [std.modules]) in a hosted implementation shall behave as if it contains an interface unit that defines an unexported ios_base::Init variable with ordered initialization (6.9.3.3 [basic.start.dynamic]).
[Note ?: As a result, the definition of that variable is appearance-ordered before any declaration following the point of importation of a C++ library module. Whether such a definition exists is unobservable by a program that does not reference any of the standard iostream objects. — end note]