From patchwork Tue Apr 25 01:19:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 20131 Received: (qmail 57812 invoked by alias); 25 Apr 2017 01:19:45 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 57802 invoked by uid 89); 25 Apr 2017 01:19:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=desirable X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 25 Apr 2017 01:19:43 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A3F8CAB960; Tue, 25 Apr 2017 01:19:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A3F8CAB960 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A3F8CAB960 Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id EEFF47D656; Tue, 25 Apr 2017 01:19:43 +0000 (UTC) Subject: Re: [PATCH 1/5] Poison non-POD memset & non-trivially-copyable memcpy/memmove To: Simon Marchi References: <1492050475-9238-1-git-send-email-palves@redhat.com> <1492050475-9238-2-git-send-email-palves@redhat.com> <44b612a2b2dadc142c054a1967dc2600@polymtl.ca> Cc: gdb-patches@sourceware.org From: Pedro Alves Message-ID: <918cb021-467e-1598-745c-d7d0aa3f0c6f@redhat.com> Date: Tue, 25 Apr 2017 02:19:43 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: 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 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 >>> -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 >>> -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 */