public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Remove reundant const-qualification from cast targets
@ 2017-04-27 15:45 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2017-04-27 15:45 UTC (permalink / raw)
  To: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 562 bytes --]

static_cast<T const> and const_cast<T const> are meaningless when T is
not a class type, because the result is a prvalue and prvalues of
non-class type are unqualified. I'm removing these pointless
const-qualifications now, because I'm experimenting with a patch to
make the front-end warn about this.

	* include/ext/pb_ds/detail/list_update_map_/iterators_fn_imps.hpp
	(PB_DS_CLASS_C_DEC::end()): Remove redundant const in cast type.
	* testsuite/util/testsuite_rng.h (twister_rand_gen::get_prob()):
	Likewise.

Tested powerpc64le-linux, committed to trunk.



[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1768 bytes --]

commit e660629ac73bae7caf3e85d95cdfc6dc9d40f27a
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Apr 27 15:50:41 2017 +0100

    Remove reundant const qualification from cast targets
    
    	* include/ext/pb_ds/detail/list_update_map_/iterators_fn_imps.hpp
    	(PB_DS_CLASS_C_DEC::end()): Remove redundant const in cast type.
    	* testsuite/util/testsuite_rng.h (twister_rand_gen::get_prob()):
    	Likewise.

diff --git a/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/iterators_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/iterators_fn_imps.hpp
index 91fef51..a1b6ed5 100644
--- a/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/iterators_fn_imps.hpp
+++ b/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/iterators_fn_imps.hpp
@@ -75,6 +75,6 @@ inline typename PB_DS_CLASS_C_DEC::const_iterator
 PB_DS_CLASS_C_DEC::
 end() const
 {
-  return const_iterator(0, 0, const_cast<PB_DS_CLASS_C_DEC* const>(this));
+  return const_iterator(0, 0, const_cast<PB_DS_CLASS_C_DEC*>(this));
 }
 
diff --git a/libstdc++-v3/testsuite/util/testsuite_rng.h b/libstdc++-v3/testsuite/util/testsuite_rng.h
index fd232fc..84fa750 100644
--- a/libstdc++-v3/testsuite/util/testsuite_rng.h
+++ b/libstdc++-v3/testsuite/util/testsuite_rng.h
@@ -79,8 +79,8 @@ namespace __gnu_pbds
       {
 	const double min = m_base_generator.min();
 	const double max = m_base_generator.max();
-	const double range = static_cast<const double>(max - min);
-	const double res = static_cast<const double>(m_base_generator() - min);
+	const double range = static_cast<double>(max - min);
+	const double res = static_cast<double>(m_base_generator() - min);
 	const double ret = res / range;
 	_GLIBCXX_DEBUG_ASSERT(ret >= 0 && ret <= 1);
 	return ret;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-04-27 15:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-27 15:45 [PATCH] Remove reundant const-qualification from cast targets Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).