Boost C++ Libraries: Ticket #7538: boost::spirit::istream_iterator does not handle incrememt correctly at the end https://svn.boost.org/trac10/ticket/7538 <p> <code>boost::spirit::istream_iterator</code> (or its super class <code>multi_pass</code> )does not handle incrememt correctly at the end position. One more end char will be yielded which is incorrect: </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&lt;sstream&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/spirit/include/support_istream_iterator.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/test/minimal.hpp&gt;</span><span class="cp"></span> <span class="kt">int</span> <span class="nf">test_main</span><span class="p">(</span><span class="kt">int</span><span class="p">,</span> <span class="kt">char</span><span class="o">*</span><span class="p">[])</span> <span class="p">{</span> <span class="n">std</span><span class="o">::</span><span class="n">istringstream</span> <span class="n">in</span><span class="p">(</span><span class="s">&quot;12&quot;</span><span class="p">);</span> <span class="n">boost</span><span class="o">::</span><span class="n">spirit</span><span class="o">::</span><span class="n">istream_iterator</span> <span class="n">it</span><span class="p">(</span><span class="n">in</span><span class="p">),</span> <span class="n">end</span><span class="p">;</span> <span class="n">BOOST_CHECK</span><span class="p">(</span><span class="o">*</span><span class="n">it</span><span class="o">++</span> <span class="o">==</span> <span class="sc">&#39;1&#39;</span><span class="p">);</span> <span class="n">BOOST_CHECK</span><span class="p">(</span><span class="o">*</span><span class="n">it</span><span class="o">++</span> <span class="o">==</span> <span class="sc">&#39;2&#39;</span><span class="p">);</span> <span class="c1">// it should be end now, however it failed</span> <span class="n">BOOST_CHECK</span><span class="p">(</span><span class="n">it</span> <span class="o">==</span> <span class="n">end</span><span class="p">);</span> <span class="c1">// !failed here</span> <span class="c1">// and yield the last char once more</span> <span class="n">BOOST_CHECK</span><span class="p">(</span><span class="o">*</span><span class="n">it</span> <span class="o">!=</span> <span class="sc">&#39;2&#39;</span><span class="p">);</span> <span class="c1">// !failed here</span> <span class="c1">// only after another dereference will it really equal to end</span> <span class="n">BOOST_CHECK</span><span class="p">(</span><span class="n">it</span> <span class="o">==</span> <span class="n">end</span><span class="p">);</span> <span class="k">return</span> <span class="mi">0</span><span class="p">;</span> <span class="p">}</span> </pre></div></div><p> The output is: </p> <pre class="wiki">test.cpp(14): test it == end failed in function: 'int test_main(int, char **)' test.cpp(16): test *it != '2' failed in function: 'int test_main(int, char **)' **** 2 errors detected </pre><p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6750" title="#6750: Bugs: istream_iterator in spirit might have defect (closed: fixed)">#6750</a> may be a duplicated issue. </p> <p> Reproducable under: </p> <ul><li>Apple clang version 4.1 (tags/Apple/clang-421.11.65) (based on LLVM 3.1svn) </li><li>Target: x86_64-apple-darwin12.2.0 </li><li>With C++ 11 turn on: "-std=c++11 -stdlib=libc++" </li><li>Boost 1.52 and Boost Trunk rev.81030 </li></ul><p> </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7538 Trac 1.4.3 code@… Sat, 09 May 2015 23:04:22 GMT <link>https://svn.boost.org/trac10/ticket/7538#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7538#comment:1</guid> <description> <p> I would mark this as rejected (or similar). I tried this with: </p> <pre class="wiki">Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn) Target: x86_64-apple-darwin13.4.0 Thread model: posix </pre><p> and only the <code>BOOST_CHECK(*it != '2');</code> check failed. However, thats undefined iterator behavior since the iterator currnetly equals the end. So I'm not sure what caused this, but it doesn't show up on newer clang-Apple builds. </p> </description> <category>Ticket</category> </item> <item> <author>code@…</author> <pubDate>Sat, 09 May 2015 23:08:23 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7538#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7538#comment:2</guid> <description> <p> I forgot to mention that I was testing against the develop branch of spirit, everything else in boost was the current master branch. The last commit was for spirit was <code>850c71a3d78665359911a15911cf263763087eff</code>. </p> </description> <category>Ticket</category> </item> </channel> </rss>