From patchwork Wed May 16 00:57:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 914100 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-477734-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="lsVB8e9n"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40lwz46f1Qz9s0W for ; Wed, 16 May 2018 10:58:05 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=PPlz8AUOov7Q4p8DXTL2mR88RJKEsz6/2Ilj+KD7TA/kGK 0XcLvF0d9vhKRs8fK1KGaqdpqepXqSt5Cose1S1mGBKm4emMUzs7wLJrsayuS45e bgF9cJepKa/YRJEyNTYQLHGX/SkvOyOnBlW+VyXR9etARR+ZeWno+L73nAIqM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=1sA8QayHq3Cbscd91qyDCiAdVgk=; b=lsVB8e9nluUtAVulgaxR 6x4MTSkcBYwBxSB8ekfYR8gyCeL7auHmJbPGfDVTYCdtTet/Bm32x3860HROsoCT yKh5nfAAI93mzLqwWX7DpWFFW0/s0WrEeQZSOSH2EPPw1wNtT3bpXj4U2rp50iZl ueA7b1vG1dYq2CguXDHG61g= Received: (qmail 4546 invoked by alias); 16 May 2018 00:57:58 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 4470 invoked by uid 89); 16 May 2018 00:57:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=deliberately, HX-Received:sk:g3-v6mr X-HELO: mail-ot0-f172.google.com Received: from mail-ot0-f172.google.com (HELO mail-ot0-f172.google.com) (74.125.82.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 16 May 2018 00:57:55 +0000 Received: by mail-ot0-f172.google.com with SMTP id i5-v6so2481498otf.1 for ; Tue, 15 May 2018 17:57:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=szVeA/ewZN4m7bXlrs8RGAbi8n84uHTw+5iSTMfP9Uo=; b=K2PVZyaKk5K5xjtI8CX+RLLBcImNz7n/Blxo9V+b8gJ8yqe7yLbHa8WayY8735U2Px +7VDIL791JPgo5+13Z6FzgTmWodGanE+lFU08h9SibLoGc/8w2+Kruf9EiB5GU2CnMFL R6/mYAO0iVNBgGQPHXddFPKYx24IYqujz1mAlHC61rwG8hA9lri+OXaY5hYGjFTnHYwY ggXhu0gHNNlJOh/D6AX1Eqe4aVKJHIkCZbJYljUHb9sYIQFoVsCthRzCpMIxJHqdDQb/ sVNIE1+8/llWJB2Z38gTANN+C9CIMwR20pUXhFRgD9Tf9OsRyzRPvShlEqHIo6t99cvb fNRQ== X-Gm-Message-State: ALKqPweSB2VHdYNlmGl/0V7TXU79cCDUwLtxaTHqdbxYL6PXkXqhixta O2Ha1wsLjOKQDyVDHtfTIixk+w+vbwK3QTz5UF42yDt1dXs= X-Google-Smtp-Source: AB8JxZoXIiAeGuyW7/38ttJhT+JysiduKfzUVUZ55UxZCAqILNN15E90DyrRYmwaSefEJNexccNjlt9wSeT8ZUnsvKk= X-Received: by 2002:a9d:1103:: with SMTP id g3-v6mr13103032ote.313.1526432273775; Tue, 15 May 2018 17:57:53 -0700 (PDT) MIME-Version: 1.0 Received: by 10.201.13.229 with HTTP; Tue, 15 May 2018 17:57:33 -0700 (PDT) From: Jason Merrill Date: Tue, 15 May 2018 20:57:33 -0400 Message-ID: Subject: RFA (ipa-prop): PATCHes to avoid use of deprecated copy ctor and op= To: gcc-patches List X-IsSubscribed: yes In C++11 and up, the implicitly-declared copy constructor and assignment operator are deprecated if one of them, or the destructor, is user-provided. Implementing that in G++ turned up a few dodgy uses in the compiler. In general it's unsafe to copy an ipa_edge_args, because if one of the pointers is non-null you get two copies of a vec pointer, and when one of the objects is destroyed it frees the vec and leaves the other object pointing to freed memory. This specific example is safe because it only copies from an object with null pointers, but it would be better to avoid the copy. OK for trunk? It's unsafe to copy a releasing_vec for the same reason. There are a few places where the copy constructor is nominally used to initialize a releasing_vec variable from a temporary returned from a function; in these cases no actual copy is done, and the function directly initializes the variable, so it's safe. I made this clearer by declaring the copy constructor but not defining it, so uses that get elided are accepted, but uses that actually want to copy will fail to link. In cp_expr we defined the copy constructor to do the same thing that the implicit definition would do, causing the copy assignment operator to be deprecated. We don't need the copy constructor, so let's remove it. Tested x86_64-pc-linux-gnu. Are the ipa-prop bits OK for trunk? commit 648ffd02e23ac2695de04ab266b4f8862df6c2ed Author: Jason Merrill Date: Tue May 15 20:46:54 2018 -0400 * cp-tree.h (cp_expr): Remove copy constructor. * mangle.c (struct releasing_vec): Declare copy constructor. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 9a2eb3be4d1..cab926028b8 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -59,9 +59,6 @@ public: cp_expr (tree value, location_t loc): m_value (value), m_loc (loc) {} - cp_expr (const cp_expr &other) : - m_value (other.m_value), m_loc (other.m_loc) {} - /* Implicit conversions to tree. */ operator tree () const { return m_value; } tree & operator* () { return m_value; } diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 6a7df804caf..59a3111fba2 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -1555,6 +1555,10 @@ struct releasing_vec releasing_vec (vec_t *v): v(v) { } releasing_vec (): v(make_tree_vector ()) { } + /* Copy constructor is deliberately declared but not defined, + copies must always be elided. */ + releasing_vec (const releasing_vec &); + vec_t &operator* () const { return *v; } vec_t *operator-> () const { return v; } vec_t *get () const { return v; }