This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [tree.c] Replace cast to (char *) by const_cast<char *>
- From: Jeff Law <law at redhat dot com>
- To: Prathamesh Kulkarni <prathamesh dot kulkarni at linaro dot org>, Nick Clifton <nickc at redhat dot com>
- Cc: gcc Patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 18 Jun 2018 08:34:28 -0600
- Subject: Re: [tree.c] Replace cast to (char *) by const_cast<char *>
- References: <CAAgBjMnCKFPthT-6zs+hm=WuWJEEA4ntYyiEyT3jq-Sp4Mtspg@mail.gmail.com> <0cdfc45c-9b14-0124-5263-15277147a0e3@redhat.com> <CAAgBjM=qz36ZFEgf+zdsHFY3S0voVgwXt7nV=LHJEZHNj0G6CQ@mail.gmail.com>
On 06/18/2018 08:08 AM, Prathamesh Kulkarni wrote:
> On 18 June 2018 at 19:28, Nick Clifton <nickc@redhat.com> wrote:
>> Hi Prathamesh,
>>
>>> I am getting the following build error with trunk:
>>> ../../gcc/gcc/tree.c: In member function ‘void
>>> escaped_string::escape(const char*)’:
>>> ../../gcc/gcc/tree.c:12457:20: error: cast from type ‘const char*’ to
>>> type ‘char*’ casts away qualifiers [-Werror=cast-qual]
>>> m_str = (char *) unescaped;
>>> ^~~~~~~~~
>>> I think this is caused by r261697 in tree.c:
>>> m_str = (char *) unescaped;
>>>
>>> The patch changes it to const_cast<char *> (unescaped) which fixes the
>>> build for me.
>>
>> I cannot approve this patch, but I can say thanks very much for catching
>> this problem and proposing a fix. I guess that I must be using an old
>> version of g++ for my testing as this error did not show up. :-(
> Hi Nick,
> Thanks for confirming. I went ahead and committed the patch in r261700
> since I guess it's trivial enough to fit under the "obvious" rule.
Yes.
Thanks for taking care of it.
jeff