This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA 7/8] Use unique_xmalloc_ptr in execute_gdb_command


On 12/22/2016 02:49 PM, Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
> 
> Tom> Probably this should use __attribute__((warn_unused_result)), but that
> Tom> isn't wrapped in ansidecl.h (yet) and I don't know offhand what version
> Tom> test to use for it.  Do you?
> 
> Pedro> Good idea.  Looks like it's GCC 3.4.
> 
> This turns out not to work :(
> 
> FWIW in addition to the ATTRIBUTE_WARN_UNUSED_RESULT patch, I also had
> to patch gdb's configure script to add -Wunused-result, as -Wunused
> turns this off.
> 

Bummer.  :-(

> The g++ bug is known:
> 
>     https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38172
> 

> It looks like the accepted fix upstream to use the C++17 [[nodiscard]]
> attribute; not sure if we can use that somehow.

Can't see why not, if we put it behind some ATTRIBUTE_NODISCARD or
some such define.  Sounds like with that we could put the attribute in
the scoped_restore_impl template itself ('struct [[nodiscard]] foo'),
and get the warning for all similar make_foo_scoped_restore-like
functions for free.

> 
> Meanwhile I'm going to drop this part of my patch.

That's fine, we can always add it later.  Thanks much for experimenting.

Thanks,
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]