This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++23 status.
import std;
should guarantee initialization of standard iostreams objectsSection: 31.4.2 [iostream.objects.overview] Status: C++23 Submitter: Tim Song Opened: 2023-02-09 Last modified: 2024-01-29
Priority: Not Prioritized
View all other issues in [iostream.objects.overview].
View all issues with C++23 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.
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 Approved at February 2023 meeting in Issaquah. 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]).