Title
Did LWG 1123 go too far?
Status
c++17
Section
[ios.init]
Submitter
Richard Smith

Created on 2016-08-13.00:00:00 last changed 89 months ago

Messages

Date: 2016-09-12.18:40:18

Proposed resolution:

This wording is relative to N4606.

  1. 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.

Date: 2016-09-09.00:00:00

[ 2016-09-09 Issues Resolution Telecon ]

P0; move to Tentatively Ready

Date: 2016-08-13.00:00:00

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?

History
Date User Action Args
2017-07-30 20:15:43adminsetstatus: wp -> c++17
2016-11-14 03:59:28adminsetstatus: pending -> wp
2016-11-14 03:55:22adminsetstatus: ready -> pending
2016-09-12 18:40:18adminsetmessages: + msg8520
2016-09-12 04:36:33adminsetmessages: + msg8507
2016-09-12 04:36:33adminsetstatus: new -> ready
2016-08-13 00:00:00admincreate