Bug 11504 - -Wcast-qual vs. stl_tree
Summary: -Wcast-qual vs. stl_tree
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 3.4.0
: P2 normal
Target Milestone: 3.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-07-11 21:28 UTC by Benjamin Kosnik
Modified: 2003-09-23 20:24 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-07-12 01:23:52


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Kosnik 2003-07-11 21:28:21 UTC
-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;
Comment 1 Andrew Pinski 2003-07-12 01:23:52 UTC
I can confirm this on the mainline (20030711), this is annoying behaviour.
Comment 2 Gerald Pfeifer 2003-07-14 16:53:15 UTC
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);
    }
Comment 3 GCC Commits 2003-07-30 15:02:03 UTC
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

Comment 4 Dara Hazeghi 2003-08-23 00:47:58 UTC
Patch went in on 7/30. Ben, does this fix your problem?
Comment 5 Gerald Pfeifer 2003-08-23 07:07:04 UTC
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
Comment 6 Benjamin Kosnik 2003-09-01 13:21:59 UTC
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
Comment 7 Benjamin Kosnik 2003-09-03 12:15:39 UTC
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)
  ])
  
Comment 8 GCC Commits 2003-09-18 14:27:33 UTC
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

Comment 9 Benjamin Kosnik 2003-09-23 20:24:27 UTC
Fixed.