This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 1/5] Poison non-POD memset & non-trivially-copyable memcpy/memmove


On 04/25/2017 02:14 AM, Pedro Alves wrote:
> Below's what I pushed.

BTW, if this ever reveals problematic in such a way that it'd be desirable
to have a convenient way to disable it, we can make the overloads
trigger warnings instead, so that folks can disable the build errors
with --disable-werror (which is the default on releases).

>From 232eda6a5fca7347c6b8b1d553e792803bccba0a Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Tue, 25 Apr 2017 00:42:17 +0100
Subject: [PATCH] warnings-instead

---
 gdb/common/common-defs.h |  8 ++++++++
 gdb/common/poison.h      | 12 ++++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/gdb/common/common-defs.h b/gdb/common/common-defs.h
index 439bce6..d00543b 100644
--- a/gdb/common/common-defs.h
+++ b/gdb/common/common-defs.h
@@ -69,6 +69,14 @@
 #undef ATTRIBUTE_PRINTF
 #define ATTRIBUTE_PRINTF _GL_ATTRIBUTE_FORMAT_PRINTF
 
+#ifdef __GNUC__
+/* Introduced in gcc versions 3.1, which is older than our minimum
+   requirement.  */
+# define ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__))
+#else
+# define ATTRIBUTE_DEPRECATED
+#endif
+
 #include "libiberty.h"
 #include "pathmax.h"
 #include "gdb/signals.h"
diff --git a/gdb/common/poison.h b/gdb/common/poison.h
index a875568..ac65484 100644
--- a/gdb/common/poison.h
+++ b/gdb/common/poison.h
@@ -74,10 +74,18 @@ using BothAreRelocatable
 
 template <typename D, typename S,
 	  typename = gdb::Requires<gdb::Not<BothAreRelocatable<D, S>>>>
-void *memcpy (D *dest, const S *src, size_t n) = delete;
+ATTRIBUTE_DEPRECATED
+void *memcpy (D *dest, const S *src, size_t n)
+{
+  return memcpy ((void *) dest, (void *) src, n);
+}
 
 template <typename D, typename S,
 	  typename = gdb::Requires<gdb::Not<BothAreRelocatable<D, S>>>>
-void *memmove (D *dest, const S *src, size_t n) = delete;
+ATTRIBUTE_DEPRECATED
+void *memmove (D *dest, const S *src, size_t n)
+{
+  return memmove ((void *) dest, (void *) src, n);
+}
 
 #endif /* COMMON_POISON_H */
-- 
2.5.5



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]