[PATCH] streambuf_iterator: avoid debug-dependent behaviour
Jonathan Wakely
jwakely@redhat.com
Thu Sep 28 10:50:00 GMT 2017
On 21/09/17 07:46 +0200, François Dumont wrote:
>Gentle reminder, ok to commit ?
No. Could you and Petr please come to an agreement about what is
actually wrong with the current implementation, and agree on a
solution?
Currently you're both just proposing patches that do different things,
without indicating why one patch is better than the other.
I understand that we want to remove the debugmode-dependent behaviour,
but I'd like to see any other changes justified by references to the
standard.
>diff --git a/libstdc++-v3/testsuite/24_iterators/istreambuf_iterator/2.cc b/libstdc++-v3/testsuite/24_iterators/istreambuf_iterator/2.cc
>index b81f4d4..e3d99f9 100644
>--- a/libstdc++-v3/testsuite/24_iterators/istreambuf_iterator/2.cc
>+++ b/libstdc++-v3/testsuite/24_iterators/istreambuf_iterator/2.cc
>@@ -25,9 +25,7 @@
>
> void test02(void)
> {
>-
> typedef std::istreambuf_iterator<char> cistreambuf_iter;
>- typedef cistreambuf_iter::streambuf_type cstreambuf_type;
> const char slit01[] = "playa hermosa, liberia, guanacaste";
> std::string str01(slit01);
> std::istringstream istrs00(str01);
>@@ -35,10 +33,17 @@ void test02(void)
>
> // ctor sanity checks
> cistreambuf_iter istrb_it01(istrs00);
>- cistreambuf_iter istrb_it02;
>- std::string tmp(istrb_it01, istrb_it02);
>+ cistreambuf_iter istrb_eos;
>+ VERIFY( istrb_it01 != istrb_eos );
>+
>+ std::string tmp(istrb_it01, istrb_eos);
> VERIFY( tmp == str01 );
>
>+ VERIFY( istrb_it01 != istrb_eos );
Why should this condition be true? The std::string constructor
increments the iterator until it reaches the end-of-stream value.
This is true with our current implementation, but that seems like a
bug, not something we want to verify in the testsuite.
>+ cistreambuf_iter old = istrb_it01++;
>+ VERIFY( old == istrb_eos );
This behaviour makes no sense.
>+ VERIFY( istrb_it01 == istrb_eos );
>+
> cistreambuf_iter istrb_it03(0);
> cistreambuf_iter istrb_it04;
> VERIFY( istrb_it03 == istrb_it04 );
More information about the Libstdc++
mailing list