public inbox for jit@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@redhat.com>
To: Jonathan Wakely <jwakely@redhat.com>,
	gcc-patches@gcc.gnu.org,  jit@gcc.gnu.org
Subject: Re: [PATCH] jit: Make recording::memento non-copyable
Date: Thu, 14 Jul 2022 14:52:48 -0400	[thread overview]
Message-ID: <414d9ada67284f06d2476c0b0f1f0132d55929b2.camel@redhat.com> (raw)
In-Reply-To: <20220714184457.753413-1-jwakely@redhat.com>

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;



           reply	other threads:[~2022-07-14 18:52 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <20220714184457.753413-1-jwakely@redhat.com>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=414d9ada67284f06d2476c0b0f1f0132d55929b2.camel@redhat.com \
    --to=dmalcolm@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jit@gcc.gnu.org \
    --cc=jwakely@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).