-Wcast-qual cannot now be used with stl_tree.h after 2003-07-04 Gawain Bolton <gbolton@free.fr> * include/bits/stl_tree.h: Performance and memory usage improvements. See: http://gcc.gnu.org/ml/libstdc++/2003-07/msg00143.html http://gcc.gnu.org/ml/libstdc++/2003-07/msg00147.html Testcase: (use -Wcast-qual) #include <set> using namespace std; set<unsigned,less<unsigned> > V;
I can confirm this on the mainline (20030711), this is annoying behaviour.
Here is a more complete testcase, which triggers further warnings: #include <set> using namespace std; typedef set<unsigned,less<unsigned> > S; S v; void f(const S &w) { v.find(2); w.find(2); }
Subject: Bug 11504 CVSROOT: /cvs/gcc Module name: gcc Changes by: bkoz@gcc.gnu.org 2003-07-30 15:01:59 Modified files: libstdc++-v3 : ChangeLog libstdc++-v3/config: linker-map.gnu libstdc++-v3/include/bits: stl_tree.h libstdc++-v3/src: stl_tree.cc Log message: 2003-07-30 Gawain Bolton <gp.bolton@computer.org> PR libstdc++/11504. * include/bits/stl_tree.h: Replace C-style casts with C++-style casts. Changes to avoid casting away constness. Eliminate _Rb_tree_base_iterator class. Change _Rb_tree_iterator to use initialization lists. Move out implementation of __black_count() to... * src/stl_tree.cc: ...here and rename _Rb_tree_black_count(). Rename_Rb_tree_base_iterator::_M_increment() to _Rb_tree_increment and _Rb_tree_base_iterator::_M_decrement() to _Rb_tree_decrement. * config/linker-map.gnu: Add and change symbols here. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&r1=1.1907&r2=1.1908 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/config/linker-map.gnu.diff?cvsroot=gcc&r1=1.45&r2=1.46 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/stl_tree.h.diff?cvsroot=gcc&r1=1.27&r2=1.28 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/src/stl_tree.cc.diff?cvsroot=gcc&r1=1.1&r2=1.2
Patch went in on 7/30. Ben, does this fix your problem?
Subject: Re: -Wcast-qual vs. stl_tree On Sat, 23 Aug 2003, dhazeghi at yahoo dot com wrote: > Patch went in on 7/30. Ben, does this fix your problem? Yes, as far as I (as the original reporter, though not filer of the PR) can tell. However, before closing the PR we should make sure that this problem is now covered by the testsuite. How about adding -Wcast-qual as a default option for the entire libstdc++ testsuite? Gerald
I agree -Wcast-qual should be added to the libstdc++ warning flags. This could be done in one of three ways, in order of best to worst: 1) add them to all the warning flags when building and testing, by adding it to WARN_FLAGS in GLIBCXX_EXPORT_FLAGS (in acinclude.m4) 2) add them to --build-cxx in scripts/testsuite_flags.in so that the g++/libstdc++ runs with it 3) add it to DEFAULT_CXXFLAGS in testsuite/libstdc++-dg/normal.exp so that all the libstdc++ testruns use it. best, benjamin
Testing this, if it passes on x86/linux I'll check it in. 2003-09-03 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/11504 * acinclude.m4 (GLIBCXX_EXPORT_FLAGS): Add -Wcast-qual to WARN_FLAGS. * aclocal.m4: Regenerate. * configure: Regenerate. Index: acinclude.m4 =================================================================== RCS file: /cvs/gcc/gcc/libstdc++-v3/acinclude.m4,v retrieving revision 1.269 diff -c -p -r1.269 acinclude.m4 *** acinclude.m4 2 Sep 2003 18:46:46 -0000 1.269 --- acinclude.m4 3 Sep 2003 12:13:51 -0000 *************** AC_DEFUN(GLIBCXX_EXPORT_FLAGS, [ *** 653,659 **** OPTIMIZE_CXXFLAGS= AC_SUBST(OPTIMIZE_CXXFLAGS) ! WARN_FLAGS='-Wall -Wno-format -W -Wwrite-strings' AC_SUBST(WARN_FLAGS) ]) --- 653,659 ---- OPTIMIZE_CXXFLAGS= AC_SUBST(OPTIMIZE_CXXFLAGS) ! WARN_FLAGS='-Wall -Wno-format -W -Wwrite-strings -Wcast-qual' AC_SUBST(WARN_FLAGS) ])
Subject: Bug 11504 CVSROOT: /cvs/gcc Module name: gcc Changes by: bkoz@gcc.gnu.org 2003-09-18 14:27:25 Modified files: libstdc++-v3 : ChangeLog acinclude.m4 aclocal.m4 configure Log message: 2003-09-18 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/11504 * acinclude.m4 (GLIBCXX_EXPORT_FLAGS): Add -Wcast-qual to WARN_FLAGS, remove -Wno-format. * aclocal.m4: Regenerate. * configure: Regenerate. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&r1=1.1961&r2=1.1962 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/acinclude.m4.diff?cvsroot=gcc&r1=1.270&r2=1.271 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/aclocal.m4.diff?cvsroot=gcc&r1=1.283&r2=1.284 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/configure.diff?cvsroot=gcc&r1=1.354&r2=1.355
Fixed.