This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [PATCH] Fix path::iterator post-increment and post-decrement
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Sat, 21 Oct 2017 02:20:24 +0100
- Subject: Re: [PATCH] Fix path::iterator post-increment and post-decrement
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jwakely at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 524557EAB2
- References: <20171019140036.GA15986@redhat.com>
On 19/10/17 15:00 +0100, Jonathan Wakely wrote:
I made a dumb mistake in the post-inc and post-dec operators for
the path::iterator type, forgetting that _M_cur is sometimes null (for
a single-element path).
* include/experimental/bits/fs_path.h (path::iterator++(int))
(path::iterator--(int)): Fix for paths with only one component.
* testsuite/experimental/filesystem/path/itr/traversal.cc: Test
post-increment and post-decrement.
And I made another dumb mistake in the new test, incrementing an end
iterator. It was caught by testing with _GLIBCXX_ASSERTIONS though.
Tested powerpc64le-linux, committed to trunk and gcc-7-branch.
commit b978785e751acf12d2429f19130900f419136e34
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Sat Oct 21 02:11:37 2017 +0100
Fix invalid path::iterator test
* testsuite/experimental/filesystem/path/itr/traversal.cc: Do not
increment past-the-end iterators.
diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/itr/traversal.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/itr/traversal.cc
index dbb4d46796d..41a292af4db 100644
--- a/libstdc++-v3/testsuite/experimental/filesystem/path/itr/traversal.cc
+++ b/libstdc++-v3/testsuite/experimental/filesystem/path/itr/traversal.cc
@@ -90,10 +90,9 @@ test03()
++iter;
iter2++;
VERIFY( iter2 == iter );
- auto iter3 = iter;
- --iter3;
+ --iter;
iter2--;
- VERIFY( iter2 == iter3 );
+ VERIFY( iter2 == iter );
}
}