From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id D1D173858C54 for ; Thu, 14 Jul 2022 18:52:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D1D173858C54 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-445-ahM5E1DCOx2dhCipI3MgnA-1; Thu, 14 Jul 2022 14:52:51 -0400 X-MC-Unique: ahM5E1DCOx2dhCipI3MgnA-1 Received: by mail-qt1-f200.google.com with SMTP id x11-20020ac84d4b000000b0031ed94d739dso417767qtv.11 for ; Thu, 14 Jul 2022 11:52:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=IL2YmXMk3WC16zpB5Dqwg3cfnWp4wtsVy3HfTGp2XxU=; b=iE7cxAKHEWjfCAaGDE8U9e5PzpjtII9l9ShtPb+61yQxpJpFMfOTlvfa5BgT6PBR+a x7Po5zn5p6S7rFXCKSiNzginbD7EEMV14opxw+1ZaBE2+aiTzX9wAlxD5M4gunwDQVzG lOgr7zG9GPNgFcfTjpb7qaWxdW7aMh18N4i4joqy9hPPSqULQcDQGDMwlyKi4Ngj3Jaf qW9zNlzfOdogkjZyYfMc3BYb6e1gLaEySr7z2EckiktJ8m8qI8VVPL874mkrkUSfPfPY i8j75BrM2Bfe/olY/tutETW4Che4PSuNT00NXv3GKUbwtAmSu7cZHsCGoYQ5a1Jr7GCa dgsw== X-Gm-Message-State: AJIora8Si6QJRFGwuP3zsSHGVX/wSQzax0/D4N5EZaNeifEZ3fLsh07E z7JJxDG1yYtynAW1432cLD7vJhu3Dud5a0NWbzj1ZPaIteCaekskaQWPUXpWbm9CWW5Ex0S9P2p 2TUsDaZQ= X-Received: by 2002:a05:620a:27c5:b0:6b5:c594:ee48 with SMTP id i5-20020a05620a27c500b006b5c594ee48mr2247757qkp.751.1657824770795; Thu, 14 Jul 2022 11:52:50 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ufKtqMGTsTI1E+VUMpdxzGsHrO2671DgaqktCx9LtjlX3qLVocHh6cfUtFdHOmDzpETcDXLQ== X-Received: by 2002:a05:620a:27c5:b0:6b5:c594:ee48 with SMTP id i5-20020a05620a27c500b006b5c594ee48mr2247744qkp.751.1657824770523; Thu, 14 Jul 2022 11:52:50 -0700 (PDT) Received: from t14s.localdomain (c-73-69-212-193.hsd1.nh.comcast.net. [73.69.212.193]) by smtp.gmail.com with ESMTPSA id i25-20020a05620a145900b006b5c2a1dea5sm1895095qkl.95.2022.07.14.11.52.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Jul 2022 11:52:49 -0700 (PDT) Message-ID: <414d9ada67284f06d2476c0b0f1f0132d55929b2.camel@redhat.com> Subject: Re: [PATCH] jit: Make recording::memento non-copyable From: David Malcolm To: Jonathan Wakely , gcc-patches@gcc.gnu.org, jit@gcc.gnu.org Date: Thu, 14 Jul 2022 14:52:48 -0400 In-Reply-To: <20220714184457.753413-1-jwakely@redhat.com> References: <20220714184457.753413-1-jwakely@redhat.com> User-Agent: Evolution 3.38.4 (3.38.4-1.fc33) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, BODY_8BITS, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: jit@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Jit mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jul 2022 18:52:54 -0000 On Thu, 2022-07-14 at 19:44 +0100, Jonathan Wakely wrote: > These polymoprhic types don't appear to be copied anywhere. Rather > than > trying to reason about what it means to copy a polymoprhic base > without > copying the derived part, disable copies. This also avoids a > potential > double-free if a recorindg::string object does somehow get copied (it > owns a pointer to dynamically allocated memory, but the implicit copy > constructor will just make shallow copies). > > Tested x86_64-linux with --enable-languages=c,c++,jit --enable-host- > shared > > OK for trunk? [CCing jit mailing list] Thanks; OK for trunk. > > -- >8 -- > > gcc/jit/ChangeLog: > >         * jit-recording.h (recording::memento): Define copy > constructor >         and copy assignment operator as deleted. >         (recording::string): Likewise. >         (recording::string::c_str): Add const qualifier. > --- >  gcc/jit/jit-recording.h | 8 +++++++- >  1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h > index 0dfb42f2676..8610ea988bd 100644 > --- a/gcc/jit/jit-recording.h > +++ b/gcc/jit/jit-recording.h > @@ -405,6 +405,9 @@ public: >    virtual void write_reproducer (reproducer &r) = 0; >    virtual location *dyn_cast_location () { return NULL; } >   > +  memento (const memento&) = delete; > +  memento& operator= (const memento&) = delete; > + >  protected: >    memento (context *ctxt) >    : m_ctxt (ctxt), > @@ -436,13 +439,16 @@ public: >    string (context *ctxt, const char *text, bool escaped); >    ~string (); >   > -  const char *c_str () { return m_buffer; } > +  const char *c_str () const { return m_buffer; } >   >    static string * from_printf (context *ctxt, const char *fmt, ...) >      GNU_PRINTF(2, 3); >   >    void replay_into (replayer *) final override {} >   > +  string (const string&) = delete; > +  string& operator= (const string&) = delete; > + >  private: >    string * make_debug_string () final override; >    void write_reproducer (reproducer &r) final override;