This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: C++ PATCH to forbid use of bool with the ++ operator
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: Marek Polacek <polacek at redhat dot com>
- Cc: Jason Merrill <jason at redhat dot com>, Martin Sebor <msebor at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, libstdc++ at gcc dot gnu dot org
- Date: Thu, 15 Sep 2016 11:18:29 +0100
- Subject: Re: C++ PATCH to forbid use of bool with the ++ operator
- Authentication-results: sourceware.org; auth=none
- References: <20160913183633.GO19950@redhat.com> <57D859CC.8020001@gmail.com> <CADzB+2nQTUZ42dh5yhP8BkJ3iUhuDnXV0zB4pngFgmS2hgENfg@mail.gmail.com> <20160914152851.GW19950@redhat.com>
On 14/09/16 17:28 +0200, Marek Polacek wrote:
diff --git gcc/libstdc++-v3/testsuite/23_containers/vector/debug/insert6_neg.cc gcc/libstdc++-v3/testsuite/23_containers/vector/debug/insert6_neg.cc
index 9893293..c939c22 100644
--- gcc/libstdc++-v3/testsuite/23_containers/vector/debug/insert6_neg.cc
+++ gcc/libstdc++-v3/testsuite/23_containers/vector/debug/insert6_neg.cc
@@ -16,6 +16,7 @@
// <http://www.gnu.org/licenses/>.
//
// { dg-do run { xfail *-*-* } }
+// { dg-options "-Wno-deprecated" }
#include <vector>
#include <debug/vector>
I'm replacing this part with a fix to avoid incrementing bool in the
testsuite, because otherwise generate_unique<bool>::build() only ever
returns true. This way it still doesn't return unique values, but at
least it alternates between true and false, and is valid for C++17.
Tested x86_64-linux, committed to trunk.
commit 4137ef6dbe7915f61c0451e10e7d91376421804c
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Thu Sep 15 10:48:26 2016 +0100
Fix testsuite to not increment bool
* testsuite/23_containers/vector/debug/insert6_neg.cc: Remove
-Wno-deprecated.
* testsuite/util/debug/checks.h (generate_unique<bool>): Specialize.
diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/insert6_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/insert6_neg.cc
index c939c22..9893293 100644
--- a/libstdc++-v3/testsuite/23_containers/vector/debug/insert6_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/vector/debug/insert6_neg.cc
@@ -16,7 +16,6 @@
// <http://www.gnu.org/licenses/>.
//
// { dg-do run { xfail *-*-* } }
-// { dg-options "-Wno-deprecated" }
#include <vector>
#include <debug/vector>
diff --git a/libstdc++-v3/testsuite/util/debug/checks.h b/libstdc++-v3/testsuite/util/debug/checks.h
index 5a40608..872fa1a 100644
--- a/libstdc++-v3/testsuite/util/debug/checks.h
+++ b/libstdc++-v3/testsuite/util/debug/checks.h
@@ -53,6 +53,19 @@ namespace __gnu_test
}
};
+ template<>
+ struct generate_unique<bool>
+ {
+ typedef bool value_type;
+
+ value_type build()
+ {
+ static value_type _S_;
+ _S_ = !_S_;
+ return _S_;
+ }
+ };
+
template<typename _Tp1, typename _Tp2>
struct generate_unique<std::pair<_Tp1, _Tp2> >
{