This is the mail archive of the mailing list for the libstdc++ 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]

Re: New istreambuf_iterator debug check

On 24/01/2018 18:53, Petr Ovtchenkov wrote:
On Wed, 24 Jan 2018 17:39:59 +0100
François Dumont <> wrote:


      I'd like to propose this new debug check. Comparing with non-eos
istreambuf_iterator sounds like an obvious coding mistake.

      I propose it despite the stage 1 as it is just a new debug check,
it doesn't impact the lib in normal mode.

      Tested under Linux x86_64, ok to commit ?


        equal(const istreambuf_iterator& __b) const
-      { return _M_at_eof() == __b._M_at_eof(); }
+      {
+	bool __this_at_eof = _M_at_eof();
+	bool __b_at_eof = __b._M_at_eof();
+	__glibcxx_requires_cond(__this_at_eof || __b_at_eof, _M_message(
+	  "Abnormal comparison to non-end-of-stream istreambuf_iterator"));
+	return __this_at_eof == __b_at_eof;
+      }

Looks strange for me. It is legal and possible that istreambuf_iterator
will be in EOF state.

Sure, but consider rather the associated showing the debug check purpose:

  cistreambuf_iter it1(istrs), it2(istrs);
  it1 == it2; // No sens

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