public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/ranger] libstdc++: Fix comment on __memcpyable
@ 2020-06-17 19:25 Aldy Hernandez
  0 siblings, 0 replies; only message in thread
From: Aldy Hernandez @ 2020-06-17 19:25 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:94f7d7ec6ebef49a50da777fd71db3d03ee03aa0

commit 94f7d7ec6ebef49a50da777fd71db3d03ee03aa0
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Mar 4 15:34:05 2020 +0000

    libstdc++: Fix comment on __memcpyable
    
    The discussion of iterator_traits<volatile T*>::value_type and  the
    example with three tempalte arguments related to an earlier version of
    the patch, not the one committed.
    
    Also improve the comment on __memcmpable.
    
            * include/bits/cpp_type_traits.h (__memcpyable): Fix comment.

Diff:
---
 libstdc++-v3/ChangeLog                      |  4 ++++
 libstdc++-v3/include/bits/cpp_type_traits.h | 11 +++++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index ff8ae64d477..df3b040abca 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,7 @@
+2020-03-04  Jonathan Wakely  <jwakely@redhat.com>
+
+	* include/bits/cpp_type_traits.h (__memcpyable): Fix comment.
+
 2020-03-04  Patrick Palka  <ppalka@redhat.com>
 
 	PR libstdc++/94017
diff --git a/libstdc++-v3/include/bits/cpp_type_traits.h b/libstdc++-v3/include/bits/cpp_type_traits.h
index fac6e4bbea2..979ad9c2c69 100644
--- a/libstdc++-v3/include/bits/cpp_type_traits.h
+++ b/libstdc++-v3/include/bits/cpp_type_traits.h
@@ -429,10 +429,9 @@ __INT_N(__GLIBCXX_TYPE_INT_N_3)
       enum { __value = __is_trivially_copyable(_Tp) };
     };
 
-  // Cannot use memcpy/memmove/memcmp on volatile types, but before C++20
-  // iterator_traits<volatile T*>::value_type is volatile T and so the
-  // partial specializations below match for volatile-qualified pointers
-  // e.g. __memcpyable<volatile int*, volatile int*, volatile int>.
+  // Cannot use memcpy/memmove/memcmp on volatile types even if they are
+  // trivially copyable, so ensure __memcpyable<volatile int*, volatile int*>
+  // and similar will be false.
   template<typename _Tp>
     struct __is_nonvolatile_trivially_copyable<volatile _Tp>
     {
@@ -457,6 +456,10 @@ __INT_N(__GLIBCXX_TYPE_INT_N_3)
     { };
 
   // Whether two iterator types can be used with memcmp.
+  // This trait only says it's well-formed to use memcmp, not that it
+  // gives the right answer for a given algorithm. So for example, std::equal
+  // needs to add additional checks that the types are integers or pointers,
+  // because other trivially copyable types can overload operator==.
   template<typename _Iter1, typename _Iter2>
     struct __memcmpable
     {


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

only message in thread, other threads:[~2020-06-17 19:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-17 19:25 [gcc/devel/ranger] libstdc++: Fix comment on __memcpyable Aldy Hernandez

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).