Boost C++ Libraries: Ticket #8164: basic_text_iprimitive loads garbage instead of throwing https://svn.boost.org/trac10/ticket/8164 <p> Hi, </p> <p> When loading several objects from a text_iarchive, one can load one too many object without the archive throwing an exception. In such case, the last object loaded will contain garbage. If one tries to load yet another object, then an exception is thrown. Here is a minimal working example to show the issue: </p> <pre class="wiki">#include &lt;boost/archive/text_iarchive.hpp&gt; #include &lt;boost/archive/text_oarchive.hpp&gt; #include &lt;iostream&gt; #include &lt;sstream&gt; int main() { std::stringstream ss; { boost::archive::text_oarchive oarchive(ss); char a = 'a', b = 'b'; oarchive &lt;&lt; a &lt;&lt; b; } std::cout &lt;&lt; "saved: \"" &lt;&lt; ss.str() &lt;&lt; "\"\n"; { boost::archive::text_iarchive iarchive(ss); char a, b, garbage, will_fail; iarchive &gt;&gt; a; std::cout &lt;&lt; "happily loaded a:\"" &lt;&lt; a &lt;&lt; "\"\n"; iarchive &gt;&gt; b; std::cout &lt;&lt; "happily loaded b:\"" &lt;&lt; b &lt;&lt; "\"\n"; iarchive &gt;&gt; garbage; std::cout &lt;&lt; "happily loaded garbage:\"" &lt;&lt; garbage &lt;&lt; "\"\n"; try { iarchive &gt;&gt; will_fail; } catch (std::exception const&amp; e) { std::cout &lt;&lt; e.what(); throw; } } } </pre><p> Attached is a patch that seems to fix the problem (and removes some trailing white spaces from the sources). I also ran all of Boost.Serialization's unit tests with the fix and everything passes except for test_array_xml_warchive, which fails with something weird and probably unrelated. </p> <p> Regards, </p> <p> Louis Dionne </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8164 Trac 1.4.3 Robert Ramey Mon, 25 Feb 2013 19:31:12 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/8164#comment:1 https://svn.boost.org/trac10/ticket/8164#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">duplicate</span> </li> </ul> Ticket