[Boost-bugs] [Boost C++ Libraries] #7538: boost::spirit::istream_iterator does not handle incrememt correctly at the end

Subject: [Boost-bugs] [Boost C++ Libraries] #7538: boost::spirit::istream_iterator does not handle incrememt correctly at the end
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-10-21 03:12:11


#7538: boost::spirit::istream_iterator does not handle incrememt correctly at the
end
--------------------------------------------------+-------------------------
 Reporter: zhuo.qiang@… | Owner: djowel
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: spirit
  Version: Boost 1.52.0 | Severity: Showstopper
 Keywords: spirit, istream_iterator, multi_pass |
--------------------------------------------------+-------------------------
 {{{boost::spirit::istream_iterator}}} (or its super class {{{multi_pass}}}
 )does not handle incrememt correctly at the end position.
 One more end char will be yielded which is incorrect:

 {{{
 #!cpp
 #include <sstream>
 #include <boost/spirit/include/support_istream_iterator.hpp>
 #include <boost/test/minimal.hpp>

 int test_main(int, char*[])
 {
     std::istringstream in("12");
     boost::spirit::istream_iterator it(in), end;

     BOOST_CHECK(*it++ == '1');
     BOOST_CHECK(*it++ == '2');

     // it should be end now, however it failed
     BOOST_CHECK(it == end); // !failed here
     // and yield the last char once more
     BOOST_CHECK(*it != '2'); // !failed here

     // only after another dereference will it really equal to end
     BOOST_CHECK(it == end);

     return 0;
 }
 }}}

 The output is:
 {{{
 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
 }}}

 #6750 may be a duplicated issue.

 Reproducable under:

 * Apple clang version 4.1 (tags/Apple/clang-421.11.65) (based on LLVM
 3.1svn)
 * Target: x86_64-apple-darwin12.2.0
 * With C++ 11 turn on: "-std=c++11 -stdlib=libc++"
 * Boost 1.52 and Boost Trunk rev.81030

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/7538>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:10 UTC