This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[commit/obvious] Use '::iterator' instead of '::const_iterator' on environ.c (and fix breakage on early versions of libstdc++)
- From: Sergio Durigan Junior <sergiodj at redhat dot com>
- To: GDB Patches <gdb-patches at sourceware dot org>
- Cc: Sergio Durigan Junior <sergiodj at redhat dot com>
- Date: Tue, 20 Jun 2017 09:37:37 -0400
- Subject: [commit/obvious] Use '::iterator' instead of '::const_iterator' on environ.c (and fix breakage on early versions of libstdc++)
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=sergiodj at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A047B40F0D
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A047B40F0D
Even though C++11 supports modifying containers using a const_iterator
(e.g., calling the 'erase' method of a std::vector), early versions of
libstdc++ did not implement that. Some of our buildslaves are using
these versions (e.g., the AArch64 buildslave uses gcc 4.8.8), and my
previous commit causes a breakage on them. The solution is simple:
just use a normal iterator, without const.
gdb/ChangeLog:
2017-06-20 Sergio Durigan Junior <sergiodj@redhat.com>
* common/environ.c (gdb_environ::unset): Use '::iterator' instead
of '::const_iterator'.
---
gdb/ChangeLog | 5 +++++
gdb/common/environ.c | 4 ++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 77001fa..f4e2b08 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2017-06-20 Sergio Durigan Junior <sergiodj@redhat.com>
+ * common/environ.c (gdb_environ::unset): Use '::iterator' instead
+ of '::const_iterator'.
+
+2017-06-20 Sergio Durigan Junior <sergiodj@redhat.com>
+
* Makefile.in (SUBDIR_UNITTESTS_SRCS): Add
'unittests/environ-selftests.c'.
(SUBDIR_UNITTESTS_OBS): Add 'environ-selftests.o'.
diff --git a/gdb/common/environ.c b/gdb/common/environ.c
index 20f8aba..2d13957 100644
--- a/gdb/common/environ.c
+++ b/gdb/common/environ.c
@@ -116,8 +116,8 @@ gdb_environ::unset (const char *var)
/* We iterate until '.cend () - 1' because the last element is
always NULL. */
- for (std::vector<char *>::const_iterator el = m_environ_vector.cbegin ();
- el != m_environ_vector.cend () - 1;
+ for (std::vector<char *>::iterator el = m_environ_vector.begin ();
+ el != m_environ_vector.end () - 1;
++el)
if (match_var_in_string (*el, var, len))
{
--
2.9.3