New istreambuf_iterator debug check
Petr Ovtchenkov
ptr@void-ptr.info
Wed Jan 24 17:53:00 GMT 2018
On Wed, 24 Jan 2018 17:39:59 +0100
François Dumont <frs.dumont@gmail.com> wrote:
> Hi
>
> 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 ?
>
> François
>
bool
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.
--
- ptr
More information about the Libstdc++
mailing list