Patchwork [libstdc++] : Avoid -Wcast-qual warnings in src/c++98/compatibility.cc

login
register
mail settings
Submitter Uros Bizjak
Date Aug. 14, 2013, 2:22 p.m.
Message ID <CAFULd4ZU8TUf+VZ8=mdwpinKN7tT9TY==2K_NBZrzj-KSvctng@mail.gmail.com>
Download mbox | patch
Permalink /patch/267137/
State New
Headers show

Comments

Uros Bizjak - Aug. 14, 2013, 2:22 p.m.
On Wed, Aug 14, 2013 at 4:05 PM, Gabriel Dos Reis
<gdr@integrable-solutions.net> wrote:
> I agree 'const void*' is preferable, and all the places you mention should
> be covered too.

I already installed my original patch, so attached incremental patch
implements preferred solution.

2013-08-14  Uros Bizjak  <ubizjak@gmail.com>

        * src/c++98/compatibility.cc (_ZTIe): Use (const cast *)
        to avoid -Wcast-qual warnings.
        (_ZTIPe): Ditto.
        (ZTIPKe): Ditto.

Tested on alphaev68-pc-linux-gnu and installed on mainline SVN.

Is this solution also OK for other release branches?

Uros.
Jakub Jelinek - Aug. 14, 2013, 2:23 p.m.
On Wed, Aug 14, 2013 at 04:22:07PM +0200, Uros Bizjak wrote:
> On Wed, Aug 14, 2013 at 4:05 PM, Gabriel Dos Reis
> <gdr@integrable-solutions.net> wrote:
> > I agree 'const void*' is preferable, and all the places you mention should
> > be covered too.
> 
> I already installed my original patch, so attached incremental patch
> implements preferred solution.
> 
> 2013-08-14  Uros Bizjak  <ubizjak@gmail.com>
> 
>         * src/c++98/compatibility.cc (_ZTIe): Use (const cast *)
>         to avoid -Wcast-qual warnings.
>         (_ZTIPe): Ditto.
>         (ZTIPKe): Ditto.
> 
> Tested on alphaev68-pc-linux-gnu and installed on mainline SVN.
> 
> Is this solution also OK for other release branches?

If it is ok for trunk, then it is also ok for 4.8/4.7 from RM POV.

	Jakub
Gabriel Dos Reis - Aug. 14, 2013, 2:34 p.m.
On Wed, Aug 14, 2013 at 9:22 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
>
> On Wed, Aug 14, 2013 at 4:05 PM, Gabriel Dos Reis
> <gdr@integrable-solutions.net> wrote:
> > I agree 'const void*' is preferable, and all the places you mention should
> > be covered too.
>
> I already installed my original patch, so attached incremental patch
> implements preferred solution.
>
> 2013-08-14  Uros Bizjak  <ubizjak@gmail.com>
>
>         * src/c++98/compatibility.cc (_ZTIe): Use (const cast *)
>         to avoid -Wcast-qual warnings.
>         (_ZTIPe): Ditto.
>         (ZTIPKe): Ditto.
>
> Tested on alphaev68-pc-linux-gnu and installed on mainline SVN.
>
> Is this solution also OK for other release branches?
>
> Uros.

Sorry, when I said 'const void*' was OK, I implicitly assumed that you would
use C++-style cast reinterpret_cast<const void*>(_Z….).  Same for
reinterpret_cast<const void*>(1);

-- Gaby
Uros Bizjak - Aug. 14, 2013, 2:36 p.m.
On Wed, Aug 14, 2013 at 4:34 PM, Gabriel Dos Reis
<gdr@integrable-solutions.net> wrote:
> On Wed, Aug 14, 2013 at 9:22 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
>>
>> On Wed, Aug 14, 2013 at 4:05 PM, Gabriel Dos Reis
>> <gdr@integrable-solutions.net> wrote:
>> > I agree 'const void*' is preferable, and all the places you mention should
>> > be covered too.
>>
>> I already installed my original patch, so attached incremental patch
>> implements preferred solution.
>>
>> 2013-08-14  Uros Bizjak  <ubizjak@gmail.com>
>>
>>         * src/c++98/compatibility.cc (_ZTIe): Use (const cast *)
>>         to avoid -Wcast-qual warnings.
>>         (_ZTIPe): Ditto.
>>         (ZTIPKe): Ditto.
>>
>> Tested on alphaev68-pc-linux-gnu and installed on mainline SVN.
>>
>> Is this solution also OK for other release branches?
>>
>> Uros.
>
> Sorry, when I said 'const void*' was OK, I implicitly assumed that you would
> use C++-style cast reinterpret_cast<const void*>(_Z….).  Same for
> reinterpret_cast<const void*>(1);

Ah, OK. I'll add this in a moment.

Thanks,
Uros.

Patch

Index: src/c++98/compatibility.cc
===================================================================
--- src/c++98/compatibility.cc	(revision 201723)
+++ src/c++98/compatibility.cc	(working copy)
@@ -516,18 +516,17 @@ 
 extern __attribute__((used, weak)) const char _ZTSe[2] = "e";
 extern __attribute__((used, weak)) const char _ZTSPe[3] = "Pe";
 extern __attribute__((used, weak)) const char _ZTSPKe[4] = "PKe";
-// const_casts are used to avoid -Wcast-qual warnings
 extern __attribute__((used, weak)) const void * const _ZTIe[2]
-  = { (void *) &_ZTVN10__cxxabiv123__fundamental_type_infoE[2],
-      const_cast<char*>(_ZTSe) };
+  = { (const void *) &_ZTVN10__cxxabiv123__fundamental_type_infoE[2],
+      (const void *) _ZTSe };
 extern __attribute__((used, weak)) const void * const _ZTIPe[4]
-  = { (void *) &_ZTVN10__cxxabiv119__pointer_type_infoE[2],
-      const_cast<char*>(_ZTSPe), (void *) 0L,
-      const_cast<void* const*>(_ZTIe) };
+  = { (const void *) &_ZTVN10__cxxabiv119__pointer_type_infoE[2],
+      (const void *) _ZTSPe, (const void *) 0L,
+      (const void *) _ZTIe };
 extern __attribute__((used, weak)) const void * const _ZTIPKe[4]
-  = { (void *) &_ZTVN10__cxxabiv119__pointer_type_infoE[2],
-      const_cast<char*>(_ZTSPKe), (void *) 1L,
-      const_cast<void* const*>(_ZTIe) };
+  = { (const void *) &_ZTVN10__cxxabiv119__pointer_type_infoE[2],
+      (const void *) _ZTSPKe, (const void *) 1L,
+      (const void *) _ZTIe };
 #endif // _GLIBCXX_LONG_DOUBLE_COMPAT
 
 #ifdef _GLIBCXX_SYMVER_DARWIN