This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: RFA: Sanitize deprecation messages (PR 84195)
- From: Jason Merrill <jason at redhat dot com>
- To: Martin Sebor <msebor at gmail dot com>
- Cc: Nick Clifton <nickc at redhat dot com>, David Malcolm <dmalcolm at redhat dot com>, msebor at gcc dot gnu dot org, Dodji Seketeli <dodji at redhat dot com>, gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 18 Jun 2018 13:56:33 -0400
- Subject: Re: RFA: Sanitize deprecation messages (PR 84195)
- References: <87h8qv9xhb.fsf@redhat.com> <d52484de-204e-3fdc-d661-f73e878c88f6@gmail.com> <bf74cbca-729c-1d6e-f5a1-c0bebbb6e553@redhat.com> <79784243-bf45-167f-a546-55c892ea02e9@gmail.com> <93d668b3-30d1-e898-544f-19a153325e03@redhat.com> <1518031052.26503.90.camel@redhat.com> <d64c1cc2-623e-9256-c050-3388f978ab3d@redhat.com> <0d7e6077-0d67-0c7b-5058-fc66e7c18d87@gmail.com> <c8bbce73-a6c0-0beb-20d0-e211c6ec446a@redhat.com> <1518728685.2913.14.camel@redhat.com> <e7da238c-f879-be89-d6de-4d9a48b6fea6@redhat.com> <490266ba-d4c5-2016-6a0f-bc0178f834a0@gmail.com>
On Fri, Feb 16, 2018 at 11:19 AM, Martin Sebor <msebor@gmail.com> wrote:
> On 02/16/2018 05:43 AM, Nick Clifton wrote:
>>
>> Hi David,
>>
>> Attached is a revised version of the patch which I hope addresses all
>> of your (very helpful) comments on the v3 patch.
>>
>> OK to apply once the sources are back on stage 1 ?
>
>
> Thanks (also) for adding the documentation!
>
> I have just one minor observation/suggestion for the escaped_string
> class. Feel free not to change anything, it's just a possible gotcha
> if the class were to become more widely used than it is now.
>
> Since the class manages a resource it should ideally make sure it
> doesn't try to release the same resource multiple times. I.e., its
> copy constructor and assignment operators should either "do the right
> thing" (whatever you think that is) or be made inaccessible (or declared
> deleted in C++ 11).
>
> For example:
>
> {
> escaped_string a;
> a.escape ("foo\nbar");
>
> escaped_string b (a);
> // b destroys its m_str
> // double free in a's destructor here
> }
>
> (Some day GCC will have a warning to help detect this pitfall.)
-Wdeprecated-copy, which I recently added to -Wall, will warn if such
a class is actually copied. Though I'm not sure it will stay in
-Wall, or keep that name.
Jason