<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2765: Did LWG 1123 go too far?</title>
<meta property="og:title" content="Issue 2765: Did LWG 1123 go too far?">
<meta property="og:description" content="C++ library issue. Status: C++17">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2765.html">
<meta property="og:type" content="website">
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
<meta property="og:image:alt" content="C++ logo">
<style>
  p {text-align:justify}
  li {text-align:justify}
  pre code.backtick::before { content: "`" }
  pre code.backtick::after { content: "`" }
  blockquote.note
  {
    background-color:#E0E0E0;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 1px;
    padding-bottom: 1px;
  }
  ins {background-color:#A0FFA0}
  del {background-color:#FFA0A0}
  table.issues-index { border: 1px solid; border-collapse: collapse; }
  table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
  table.issues-index td { padding: 4px; border: 1px solid; }
  table.issues-index td:nth-child(1) { text-align: right; }
  table.issues-index td:nth-child(2) { text-align: left; }
  table.issues-index td:nth-child(3) { text-align: left; }
  table.issues-index td:nth-child(4) { text-align: left; }
  table.issues-index td:nth-child(5) { text-align: center; }
  table.issues-index td:nth-child(6) { text-align: center; }
  table.issues-index td:nth-child(7) { text-align: left; }
  table.issues-index td:nth-child(5) span.no-pr { color: red; }
  @media (prefers-color-scheme: dark) {
     html {
        color: #ddd;
        background-color: black;
     }
     ins {
        background-color: #225522
     }
     del {
        background-color: #662222
     }
     a {
        color: #6af
     }
     a:visited {
        color: #6af
     }
     blockquote.note
     {
        background-color: rgba(255, 255, 255, .10)
     }
  }
</style>
</head>
<body>
<hr>
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#C++17">C++17</a> status.</em></p>
<h3 id="2765"><a href="lwg-defects.html#2765">2765</a>. Did LWG 1123 go too far?</h3>
<p><b>Section:</b> 31.5.2.2.6 <a href="https://wg21.link/ios.init">[ios.init]</a> <b>Status:</b> <a href="lwg-active.html#C++17">C++17</a>
 <b>Submitter:</b> Richard Smith <b>Opened:</b> 2016-08-13 <b>Last modified:</b> 2021-06-06</p>
<p><b>Priority: </b>0
</p>
<p><b>View all other</b> <a href="lwg-index.html#ios.init">issues</a> in [ios.init].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++17">C++17</a> status.</p>
<p><b>Discussion:</b></p>
<p>
<a href="lwg-defects.html#1123" title="No requirement that standard streams be flushed (Status: C++11)">1123</a><sup><a href="https://cplusplus.github.io/LWG/issue1123" title="Latest snapshot">(i)</a></sup> fixed a bug where users of <code>&lt;iostream&gt;</code> were not guaranteed to have their streams flushed
on program shutdown. However, it also added this rule:
</p>
<blockquote><p>
"Similarly, the entire program shall behave as if there were at least one instance of <code>ios_base::Init</code> with static
lifetime."
</p></blockquote>
<p>
This seems pointless: it only affects the behavior of programs that never include <code>&lt;iostream&gt;</code> (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.
<p/>
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.
<p/>
Can it be removed?
</p>

<p><i>[2016-09-09 Issues Resolution Telecon]</i></p>

<p>P0; move to Tentatively Ready</p>


<p id="res-2765"><b>Proposed resolution:</b></p>
<p>This wording is relative to N4606.</p>

<ol>
<li><p>Modify  [ios::Init] p3 as indicated:</p>
<blockquote><p>
-3- The objects are constructed and the associations are established at some time prior to or during the first
time an object of class <code>ios_base::Init</code> is constructed, and in any case before the body of <code>main</code> begins
execution.(footnote 293) The objects are not destroyed during program execution.(footnote 294) The results of including
<code>&lt;iostream&gt;</code> in a translation unit shall be as if <code>&lt;iostream&gt;</code> defined an instance of
<code>ios_base::Init</code> with static storage duration. <del>Similarly, the entire program shall behave as if there were at
least one instance of <code>ios_base::Init</code> with static storage duration.</del>
</p></blockquote>
</li>
</ol>





</body>
</html>
