[2/8] Dont' allow copying of auto_obstack

Message ID 20200208152758.29385-3-tom@tromey.com
State New, archived
Headers

Commit Message

Tom Tromey Feb. 8, 2020, 3:27 p.m. UTC
  Add DISABLE_COPY_AND_ASSIGN to struct auto_obstack, to prevent copying
it.  Copying an auto_obstack would be a bug.

gdb/ChangeLog
2020-02-08  Tom Tromey  <tom@tromey.com>

	* gdb_obstack.h (struct auto_obstack): Use
	DISABLE_COPY_AND_ASSIGN.

Change-Id: Ic9e5ab20acfcfa61c241fed4d99bbb1caefba3cd
---
 gdb/ChangeLog     | 5 +++++
 gdb/gdb_obstack.h | 2 ++
 2 files changed, 7 insertions(+)
  

Comments

Terekhov, Mikhail via Gdb-patches Feb. 9, 2020, 10:59 p.m. UTC | #1
On Sat, Feb 8, 2020, 10:28 Tom Tromey <tom@tromey.com> wrote:

> Add DISABLE_COPY_AND_ASSIGN to struct auto_obstack, to prevent copying
> it.  Copying an auto_obstack would be a bug.
>

Typo in the subject/first line (Dont' -> Don't)


> gdb/ChangeLog
> 2020-02-08  Tom Tromey  <tom@tromey.com>
>
>         * gdb_obstack.h (struct auto_obstack): Use
>         DISABLE_COPY_AND_ASSIGN.
>
> Change-Id: Ic9e5ab20acfcfa61c241fed4d99bbb1caefba3cd
> ---
>  gdb/ChangeLog     | 5 +++++
>  gdb/gdb_obstack.h | 2 ++
>  2 files changed, 7 insertions(+)
>
> diff --git a/gdb/gdb_obstack.h b/gdb/gdb_obstack.h
> index fb9295f5020..9b1d907678f 100644
> --- a/gdb/gdb_obstack.h
> +++ b/gdb/gdb_obstack.h
> @@ -125,6 +125,8 @@ struct auto_obstack : obstack
>    ~auto_obstack ()
>    { obstack_free (this, NULL); }
>
> +  DISABLE_COPY_AND_ASSIGN (auto_obstack);
> +
>    /* Free all memory in the obstack but leave it valid for further
>       allocation.  */
>    void clear ()
> --
> 2.17.2
>
>
  
Tom Tromey Feb. 12, 2020, 12:16 a.m. UTC | #2
>>>>> "Christian" == Christian Biesinger <cbiesinger@google.com> writes:

> On Sat, Feb 8, 2020, 10:28 Tom Tromey <tom@tromey.com> wrote:
>  Add DISABLE_COPY_AND_ASSIGN to struct auto_obstack, to prevent copying
>  it.  Copying an auto_obstack would be a bug.

Christian> Typo in the subject/first line (Dont' -> Don't)

Thanks, I fixed this.

Tom
  
Simon Marchi Feb. 12, 2020, 12:53 a.m. UTC | #3
On 2020-02-11 7:16 p.m., Tom Tromey wrote:
>>>>>> "Christian" == Christian Biesinger <cbiesinger@google.com> writes:
> 
>> On Sat, Feb 8, 2020, 10:28 Tom Tromey <tom@tromey.com> wrote:
>>  Add DISABLE_COPY_AND_ASSIGN to struct auto_obstack, to prevent copying
>>  it.  Copying an auto_obstack would be a bug.
> 
> Christian> Typo in the subject/first line (Dont' -> Don't)
> 
> Thanks, I fixed this.
> 
> Tom
> 

That makes sense, I think you should push this one right away, independently
from this series.

Simon
  
Tom Tromey Feb. 12, 2020, 1:01 a.m. UTC | #4
>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

Simon> That makes sense, I think you should push this one right away, independently
Simon> from this series.

I'll push these first two.  Thanks.

Tom
  

Patch

diff --git a/gdb/gdb_obstack.h b/gdb/gdb_obstack.h
index fb9295f5020..9b1d907678f 100644
--- a/gdb/gdb_obstack.h
+++ b/gdb/gdb_obstack.h
@@ -125,6 +125,8 @@  struct auto_obstack : obstack
   ~auto_obstack ()
   { obstack_free (this, NULL); }
 
+  DISABLE_COPY_AND_ASSIGN (auto_obstack);
+
   /* Free all memory in the obstack but leave it valid for further
      allocation.  */
   void clear ()