public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb/build: Fix Wpessimizing-move in clang build
@ 2022-01-28 13:41 Enze Li
  2022-01-28 14:25 ` Simon Marchi
  0 siblings, 1 reply; 5+ messages in thread
From: Enze Li @ 2022-01-28 13:41 UTC (permalink / raw)
  To: gdb-patches

When building with clang, I run into an error:

...
tui/tui-disasm.c:138:25: error: moving a temporary object prevents copy
elision [-Werror,-Wpessimizing-move]
      tal.addr_string = std::move (gdb_dis_out.release ());
                        ^
tui/tui-disasm.c:138:25: note: remove std::move call here
      tal.addr_string = std::move (gdb_dis_out.release ());
                        ^~~~~~~~~~~                      ~
...

The error above is caused by the recent commit 5d10a2041eb8 ("gdb: add
string_file::release method").

Fix this by removing std::move.

Build on x86_64-linux with clang 13.0.0.
---
 gdb/tui/tui-disasm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index 445503a5af9..70f7429d32b 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -135,7 +135,7 @@ tui_disassemble (struct gdbarch *gdbarch,
       /* And capture the address the instruction is at.  */
       tal.addr = orig_pc;
       print_address (gdbarch, orig_pc, &gdb_dis_out);
-      tal.addr_string = std::move (gdb_dis_out.release ());
+      tal.addr_string = gdb_dis_out.release ();
 
       if (addr_size != nullptr)
 	{
-- 
2.34.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] gdb/build: Fix Wpessimizing-move in clang build
  2022-01-28 13:41 [PATCH] gdb/build: Fix Wpessimizing-move in clang build Enze Li
@ 2022-01-28 14:25 ` Simon Marchi
  2022-01-28 14:33   ` Enze Li
  0 siblings, 1 reply; 5+ messages in thread
From: Simon Marchi @ 2022-01-28 14:25 UTC (permalink / raw)
  To: Enze Li, gdb-patches



On 2022-01-28 08:41, Enze Li via Gdb-patches wrote:
> When building with clang, I run into an error:
> 
> ...
> tui/tui-disasm.c:138:25: error: moving a temporary object prevents copy
> elision [-Werror,-Wpessimizing-move]
>       tal.addr_string = std::move (gdb_dis_out.release ());
>                         ^
> tui/tui-disasm.c:138:25: note: remove std::move call here
>       tal.addr_string = std::move (gdb_dis_out.release ());
>                         ^~~~~~~~~~~                      ~
> ...
> 
> The error above is caused by the recent commit 5d10a2041eb8 ("gdb: add
> string_file::release method").
> 
> Fix this by removing std::move.
> 
> Build on x86_64-linux with clang 13.0.0.
> ---
>  gdb/tui/tui-disasm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
> index 445503a5af9..70f7429d32b 100644
> --- a/gdb/tui/tui-disasm.c
> +++ b/gdb/tui/tui-disasm.c
> @@ -135,7 +135,7 @@ tui_disassemble (struct gdbarch *gdbarch,
>        /* And capture the address the instruction is at.  */
>        tal.addr = orig_pc;
>        print_address (gdbarch, orig_pc, &gdb_dis_out);
> -      tal.addr_string = std::move (gdb_dis_out.release ());
> +      tal.addr_string = gdb_dis_out.release ();
>  
>        if (addr_size != nullptr)
>  	{

Oh, thanks!  In fact, this is the spot that did prompt me to add this
release method, so it's a silly oversight on my part to not remove the
std::move.  Thanks patch is ok.  Do you have push access?

Simon

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] gdb/build: Fix Wpessimizing-move in clang build
  2022-01-28 14:25 ` Simon Marchi
@ 2022-01-28 14:33   ` Enze Li
  2022-01-28 14:58     ` Simon Marchi
  0 siblings, 1 reply; 5+ messages in thread
From: Enze Li @ 2022-01-28 14:33 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches

On Fri, 2022-01-28 at 09:25 -0500, Simon Marchi wrote:
> 
> 
> On 2022-01-28 08:41, Enze Li via Gdb-patches wrote:
> > When building with clang, I run into an error:
> > 
> > ...
> > tui/tui-disasm.c:138:25: error: moving a temporary object prevents
> > copy
> > elision [-Werror,-Wpessimizing-move]
> >       tal.addr_string = std::move (gdb_dis_out.release ());
> >                         ^
> > tui/tui-disasm.c:138:25: note: remove std::move call here
> >       tal.addr_string = std::move (gdb_dis_out.release ());
> >                         ^~~~~~~~~~~                      ~
> > ...
> > 
> > The error above is caused by the recent commit 5d10a2041eb8 ("gdb:
> > add
> > string_file::release method").
> > 
> > Fix this by removing std::move.
> > 
> > Build on x86_64-linux with clang 13.0.0.
> > ---
> >  gdb/tui/tui-disasm.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
> > index 445503a5af9..70f7429d32b 100644
> > --- a/gdb/tui/tui-disasm.c
> > +++ b/gdb/tui/tui-disasm.c
> > @@ -135,7 +135,7 @@ tui_disassemble (struct gdbarch *gdbarch,
> >        /* And capture the address the instruction is at.  */
> >        tal.addr = orig_pc;
> >        print_address (gdbarch, orig_pc, &gdb_dis_out);
> > -      tal.addr_string = std::move (gdb_dis_out.release ());
> > +      tal.addr_string = gdb_dis_out.release ();
> >  
> >        if (addr_size != nullptr)
> >         {
> 
> Oh, thanks!  In fact, this is the spot that did prompt me to add this
> release method, so it's a silly oversight on my part to not remove
> the
> std::move.  Thanks patch is ok.  Do you have push access?

Yes.  Should I push it now?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] gdb/build: Fix Wpessimizing-move in clang build
  2022-01-28 14:33   ` Enze Li
@ 2022-01-28 14:58     ` Simon Marchi
  2022-01-28 15:08       ` Enze Li
  0 siblings, 1 reply; 5+ messages in thread
From: Simon Marchi @ 2022-01-28 14:58 UTC (permalink / raw)
  To: Enze Li, gdb-patches



On 2022-01-28 09:33, Enze Li wrote:
> On Fri, 2022-01-28 at 09:25 -0500, Simon Marchi wrote:
>>
>>
>> On 2022-01-28 08:41, Enze Li via Gdb-patches wrote:
>>> When building with clang, I run into an error:
>>>
>>> ...
>>> tui/tui-disasm.c:138:25: error: moving a temporary object prevents
>>> copy
>>> elision [-Werror,-Wpessimizing-move]
>>>       tal.addr_string = std::move (gdb_dis_out.release ());
>>>                         ^
>>> tui/tui-disasm.c:138:25: note: remove std::move call here
>>>       tal.addr_string = std::move (gdb_dis_out.release ());
>>>                         ^~~~~~~~~~~                      ~
>>> ...
>>>
>>> The error above is caused by the recent commit 5d10a2041eb8 ("gdb:
>>> add
>>> string_file::release method").
>>>
>>> Fix this by removing std::move.
>>>
>>> Build on x86_64-linux with clang 13.0.0.
>>> ---
>>>  gdb/tui/tui-disasm.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
>>> index 445503a5af9..70f7429d32b 100644
>>> --- a/gdb/tui/tui-disasm.c
>>> +++ b/gdb/tui/tui-disasm.c
>>> @@ -135,7 +135,7 @@ tui_disassemble (struct gdbarch *gdbarch,
>>>        /* And capture the address the instruction is at.  */
>>>        tal.addr = orig_pc;
>>>        print_address (gdbarch, orig_pc, &gdb_dis_out);
>>> -      tal.addr_string = std::move (gdb_dis_out.release ());
>>> +      tal.addr_string = gdb_dis_out.release ();
>>>  
>>>        if (addr_size != nullptr)
>>>         {
>>
>> Oh, thanks!  In fact, this is the spot that did prompt me to add this
>> release method, so it's a silly oversight on my part to not remove
>> the
>> std::move.  Thanks patch is ok.  Do you have push access?
> 
> Yes.  Should I push it now?

Yes, please go ahead.

Simon

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] gdb/build: Fix Wpessimizing-move in clang build
  2022-01-28 14:58     ` Simon Marchi
@ 2022-01-28 15:08       ` Enze Li
  0 siblings, 0 replies; 5+ messages in thread
From: Enze Li @ 2022-01-28 15:08 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches

On Fri, 2022-01-28 at 09:58 -0500, Simon Marchi wrote:
> 
> 
> On 2022-01-28 09:33, Enze Li wrote:
> > On Fri, 2022-01-28 at 09:25 -0500, Simon Marchi wrote:
> > > 
> > > 
> > > On 2022-01-28 08:41, Enze Li via Gdb-patches wrote:
> > > > When building with clang, I run into an error:
> > > > 
> > > > ...
> > > > tui/tui-disasm.c:138:25: error: moving a temporary object
> > > > prevents
> > > > copy
> > > > elision [-Werror,-Wpessimizing-move]
> > > >       tal.addr_string = std::move (gdb_dis_out.release ());
> > > >                         ^
> > > > tui/tui-disasm.c:138:25: note: remove std::move call here
> > > >       tal.addr_string = std::move (gdb_dis_out.release ());
> > > >                         ^~~~~~~~~~~                      ~
> > > > ...
> > > > 
> > > > The error above is caused by the recent commit 5d10a2041eb8
> > > > ("gdb:
> > > > add
> > > > string_file::release method").
> > > > 
> > > > Fix this by removing std::move.
> > > > 
> > > > Build on x86_64-linux with clang 13.0.0.
> > > > ---
> > > >  gdb/tui/tui-disasm.c | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > 
> > > > diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
> > > > index 445503a5af9..70f7429d32b 100644
> > > > --- a/gdb/tui/tui-disasm.c
> > > > +++ b/gdb/tui/tui-disasm.c
> > > > @@ -135,7 +135,7 @@ tui_disassemble (struct gdbarch *gdbarch,
> > > >        /* And capture the address the instruction is at.  */
> > > >        tal.addr = orig_pc;
> > > >        print_address (gdbarch, orig_pc, &gdb_dis_out);
> > > > -      tal.addr_string = std::move (gdb_dis_out.release ());
> > > > +      tal.addr_string = gdb_dis_out.release ();
> > > >  
> > > >        if (addr_size != nullptr)
> > > >         {
> > > 
> > > Oh, thanks!  In fact, this is the spot that did prompt me to add
> > > this
> > > release method, so it's a silly oversight on my part to not
> > > remove
> > > the
> > > std::move.  Thanks patch is ok.  Do you have push access?
> > 
> > Yes.  Should I push it now?
> 
> Yes, please go ahead.
> 
> Simon

Okay, pushed.

Cheers!
Enze

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-01-28 15:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-28 13:41 [PATCH] gdb/build: Fix Wpessimizing-move in clang build Enze Li
2022-01-28 14:25 ` Simon Marchi
2022-01-28 14:33   ` Enze Li
2022-01-28 14:58     ` Simon Marchi
2022-01-28 15:08       ` Enze Li

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).