This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++17 status.
Section: 126.96.36.199.6 [ios.init] Status: C++17 Submitter: Richard Smith Opened: 2016-08-13 Last modified: 2021-06-06
View all other issues in [ios.init].
View all issues with C++17 status.
1123 fixed a bug where users of <iostream> were not guaranteed to have their streams flushed on program shutdown. However, it also added this rule:
"Similarly, the entire program shall behave as if there were at least one instance of ios_base::Init with static lifetime."
This seems pointless: it only affects the behavior of programs that never include <iostream> (because programs that do include it are already guaranteed at least one such instance), and those programs do not need an implicit flush because they cannot have written to the relevant streams.It's also actively harmful, because it requires the iostreams component to be linked into programs that do not use it, apparently even including freestanding implementations! Fortunately, C++ implementations appear to uniformly ignore this rule. Can it be removed?
[2016-09-09 Issues Resolution Telecon]
P0; move to Tentatively Ready
This wording is relative to N4606.
Modify [ios::Init] p3 as indicated:
-3- The objects are constructed and the associations are established at some time prior to or during the first time an object of class ios_base::Init is constructed, and in any case before the body of main begins execution.(footnote 293) The objects are not destroyed during program execution.(footnote 294) 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.
Similarly, the entire program shall behave as if there were at least one instance of ios_base::Init with static storage duration.