Hello! Attached patch avoids a bunch of -Wcast-qual warnings when building libstdc++ on alpha-linux-gnu, a _GLIBCXX_LONG_DOUBLE_COMPAT target:
../../../../gcc-svn/trunk/libstdc++-v3/src/c++98/compatibility.cc:521:16: warning: cast from type ‘const char*’ to type ‘void*’ casts away qualifiers [-Wcast-qual] (void *) _ZTSe }; ^ ../../../../gcc-svn/trunk/libstdc++-v3/src/c++98/compatibility.cc:524:16: warning: cast from type ‘const char*’ to type ‘void*’ casts away qualifiers [-Wcast-qual] (void *) _ZTSPe, (void *) 0L, (void *) _ZTIe }; ^ ../../../../gcc-svn/trunk/libstdc++-v3/src/c++98/compatibility.cc:524:46: warning: cast from type ‘const void* const*’ to type ‘void*’ casts away qualifiers [-Wcast-qual] (void *) _ZTSPe, (void *) 0L, (void *) _ZTIe }; ^ ../../../../gcc-svn/trunk/libstdc++-v3/src/c++98/compatibility.cc:527:16: warning: cast from type ‘const char*’ to type ‘void*’ casts away qualifiers [-Wcast-qual] (void *) _ZTSPKe, (void *) 1L, (void *) _ZTIe }; ^ ../../../../gcc-svn/trunk/libstdc++-v3/src/c++98/compatibility.cc:527:47: warning: cast from type ‘const void* const*’ to type ‘void*’ casts away qualifiers [-Wcast-qual] (void *) _ZTSPKe, (void *) 1L, (void *) _ZTIe }; 2013-08-07 Uros Bizjak <ubiz...@gmail.com> * src/c++98/compatibility.cc (_ZTIe): Use const_cast to avoid warning. (_ZTIPe): Ditto. (ZTIPKe): Ditto. The patch was bootstrapped on alpha-linux-gnu, regression test is still running. OK for mainline if regtest shows no problems? Also for 4.8? Uros.
Index: src/c++98/compatibility.cc =================================================================== --- src/c++98/compatibility.cc (revision 201568) +++ src/c++98/compatibility.cc (working copy) @@ -518,13 +518,15 @@ extern __attribute__((used, weak)) const char _ZTSPKe[4] = "PKe"; extern __attribute__((used, weak)) const void * const _ZTIe[2] = { (void *) &_ZTVN10__cxxabiv123__fundamental_type_infoE[2], - (void *) _ZTSe }; + const_cast<char*>(_ZTSe) }; extern __attribute__((used, weak)) const void * const _ZTIPe[4] = { (void *) &_ZTVN10__cxxabiv119__pointer_type_infoE[2], - (void *) _ZTSPe, (void *) 0L, (void *) _ZTIe }; + const_cast<char*>(_ZTSPe), (void *) 0L, + const_cast<void* const*>(_ZTIe) }; extern __attribute__((used, weak)) const void * const _ZTIPKe[4] = { (void *) &_ZTVN10__cxxabiv119__pointer_type_infoE[2], - (void *) _ZTSPKe, (void *) 1L, (void *) _ZTIe }; + const_cast<char*>(_ZTSPKe), (void *) 1L, + const_cast<void* const*>(_ZTIe) }; #endif // _GLIBCXX_LONG_DOUBLE_COMPAT #ifdef _GLIBCXX_SYMVER_DARWIN