Make istreambuf_iterator::_M_sbuf immutable and add debug checks

François Dumont frs.dumont@gmail.com
Mon Oct 23 19:08:00 GMT 2017


Hi

      I completed execution of all tests and found one test impacted by 
this patch.

      It is a good example of the impact of the patch. Users won't be 
able to build a istreambuf_iterator at a point where the underlying 
streambuf is at end-of-stream and then put some data in the streambuf 
and then use the iterator. This is similar to what Petr was proposing, 
some eof iterator becoming valid again through an operation on the 
streambuf. I would prefer we forbid it completely or we accept it 
completely but current middle way situation is strange.

      The fix is easy, let the compiler build the streambuf_iterator 
when needed. Even if patch is not accepted I think we should keep the 
change on the test which is fragile.

François


On 13/10/2017 19:14, François Dumont wrote:
> Hi
>
>      Here is the last patch I will propose for istreambuf_iterator. 
> This is mostly to remove the mutable keyword on _M_sbuf.
>
>      To do so I had to reset _M_sbuf in valid places that is to say 
> constructors and increment operators. Despite that we might still have 
> eof iterators with _M_sbuf not null when you have for instance several 
> iterator instance but only increment one. It seems fine to me because 
> even in this case iterator will still be considered as eof and using 
> several istreambuf_iterator to go through a given streambuf is not usual.
>
>      As _M_sbuf is immutable I have been able to restore the simple 
> call to _M_at_eof() in the increment operators debug check.
>
> Ok to commit after successful tests ?
>
> François
>
>
>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: immutable_streambuf_ite.patch
Type: text/x-patch
Size: 9704 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20171023/0d9960fd/attachment.bin>


More information about the Libstdc++ mailing list