This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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: [PATCH 00/18] gdb: Enable -Wwrite-strings (aka remove -Wno-write-strings)


On Tuesday, April 04 2017, Pedro Alves wrote:

> "-Wwrite-strings" is enabled by default for C++ programs:
>
>   "When compiling C++, warn about the deprecated conversion from
>   string literals to char *. This warning is enabled by default for
>   C++ programs. "
>
> This warning, via -Werror, makes this be a compile-time error:
>
>  char *str = "hello";
>
> It forces us to write instead either
>
>  char *str = (char *) "hello"; // I know what I'm doing! (TM)
>
> or:
>
>  const char *str = "hello";    // Preferable.
>
> However, I had disabled the warning for GDB in the earlier steps of
> the C++ conversion:
>
>   https://sourceware.org/ml/gdb-patches/2015-02/msg00203.html
>
> ... as an expedient hack, since we weren't enabling it in C mode
> either.
>
> I'd like to enable the warning now, to catch more bugs at compile
> time.  I spotted one related bug in review last week (storing a string
> literal in a vector of heap-allocated strings, leading to a bogus
> "free" call later on), which was what prompted me to do this.
>
> "Bah, I'll just do it.  Can't take more than a couple hours..."
>
> Yeah, right...  /me will never learn.
>
> Tested on x86_64 Fedora 23, built with --enable-targets=all.
>
> Compile tested GDB on Aarch64 GNU/Linux, Power 64 GNU/Linux, AIX 7.1,
> and 32-bit/64-bit mingw32-w64.
>
> Also cross built MIPS and ARM GNU/Linux gdbserver.
>
> The first patch needs approval from the binutils side, hence the cross
> post.  The rest of the series is GDB-specific, so I'm sending those
> patches to gdb-patches@ only.

Hey Pedro,

Thank you very much for doing this.  I love these kinds of cleanups.

I looked at all the patches (except for the last patch, which I glanced
over everything due to its size), and aside from two comments that I
already posted, the series is fine by me.

Happy to see GDB more const-correct.

Cheers,

-- 
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF  31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
http://sergiodj.net/


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