title: What Effect Would LWG2349 Have?
body: <p>While libstdc++ does not, libc++ does follow <a href="https://stackoverflow.com/a/35020134/2642059">the standard which states</a> that passing <code>ios_base::failbit</code> to <a href="http://en.cppreference.com/w/cpp/io/basic_ios/exceptions" rel="nofollow noreferrer"><code>basic_istream::exceptions</code></a> has no effect on formatted input. For example this code:</p>
  <pre><code>istringstream is{&quot;ASD&quot;};    
  double foo;
  
  is.exceptions(istream::failbit);
  
  try {
      is &gt;&gt; foo;
      cout &lt;&lt; foo &lt;&lt; endl;
  } catch(ios_base::failure&amp; fail) {
      cout &lt;&lt; &quot;ouch\n&quot;;
  }
  </code></pre>
  <p>Would result in:</p>
  <ul>
  <li><a href="http://coliru.stacked-crooked.com/a/c7b2a1560cc426b1" rel="nofollow noreferrer">&quot;ouch&quot; on libstdc++</a></li>
  <li><a href="http://coliru.stacked-crooked.com/a/23341dc0ffa0b22a" rel="nofollow noreferrer">&quot;0&quot; on libc++</a></li>
  </ul>
  <p>My reading of <a href="http://cplusplus.github.io/LWG/lwg-active.html#2349" rel="nofollow noreferrer">LWG2349</a> is that it would cause <code>basic_istream</code> to not throw on any formatted input.</p>
  <p>For example LWG2349 proposes a change to the standard's 27.7.2.3 [istream]/1 which was cited with reference to <a href="https://llvm.org/bugs/show_bug.cgi?id=15949" rel="nofollow noreferrer">the invalidation of a bug that would have made libc++ behave like libstdc++</a>. The change is in bold and strike through below:</p>
  <blockquote>
  <p>If an exception <strong>, other than the ones thrown from <code>clear()</code>, if any,</strong> is thrown during input then <code>ios::badbit</code> is turned on in <code>*this</code>’s error state. <strike>(Exceptions thrown from <code>basic_ios&lt;&gt;::clear()</code> are not caught or rethrown.)</strike> If <code>(exceptions()&amp;badbit) != 0</code> then the exception is rethrown.</p>
  </blockquote>
  <p><a href="https://chat.stackoverflow.com/rooms/101900/discussion-between-jonathan-mee-and-t-c">I understand that <code>basic_istream::clear</code> is what throws in reaction to bad formatted input</a> so am I misreading LWG2349 or is it in fact going to stop <code>basic_istream</code> from throwing any errors?</p>