This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/81964] New: istream_iterator: unexpected read in ctor


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81964

            Bug ID: 81964
           Summary: istream_iterator: unexpected read in ctor
           Product: gcc
           Version: 6.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: abominable-snowman at yandex dot ru
                CC: abominable-snowman at yandex dot ru
  Target Milestone: ---
                CC: abominable-snowman at yandex dot ru

istream_iterator do unexpected read from stream when initialized by istream&:

    ///  Construct start of input stream iterator.
    istream_iterator(istream_type& __s)
     : _M_stream(&__s)
     { _M_read(); }

but expected, that read happens on dereference at least.
See:

  std::istringstream s("1 2");
  std::istream_iterator<int> ii1(s);
  std::istream_iterator<int> ii2(s);

  VERIFY( *ii2 == 1 );
  VERIFY( *ii1 == 2 );

--- Comment #1 from Petr Ovtchenkov <abominable-snowman at yandex dot ru> ---
Created attachment 42035
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42035&action=edit
proposed solution and test

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]