This is the mail archive of the
mailing list for the binutils project.
Re: [PATCH 00/18] gdb: Enable -Wwrite-strings (aka remove -Wno-write-strings)
- From: Sergio Durigan Junior <sergiodj at redhat dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: gdb-patches at sourceware dot org, Binutils <binutils at sourceware dot org>
- Date: Tue, 04 Apr 2017 14:42:28 -0400
- Subject: Re: [PATCH 00/18] gdb: Enable -Wwrite-strings (aka remove -Wno-write-strings)
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=sergiodj at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2C5CD80480
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2C5CD80480
- References: <firstname.lastname@example.org>
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)
> const char *str = "hello"; // Preferable.
> However, I had disabled the warning for GDB in the earlier steps of
> the C++ conversion:
> ... as an expedient hack, since we weren't enabling it in C mode
> 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.
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.
GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible