This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: -Wcast-qual broken(?) for libstdc++


On Wed, Jul 16, 2003 at 04:20:43PM +0100, Gawain Bolton wrote:

> I agree that the function you are adding in your patch will be required.
> However, I think you will find that your patch will cause problems in other
> functions due to const poisoning.  This is the reason I will need time to
> solve the casting and const issues cleanly.  Currently I'm on vacation and
> unable to do this.

In the meantime, if anyone's really annoyed by the warnings, this would
silence them for both testcases given in libstdc++/11504 by using
const_cast so that -Wcast-qual doesn't complain:

diff -u -p -b -B -r1.27 stl_tree.h
--- include/bits/stl_tree.h 14 Jul 2003 02:52:04 -0000  1.27
+++ include/bits/stl_tree.h 15 Jul 2003 12:24:47 -0000
@@ -377,7 +377,7 @@ namespace std
       _M_rightmost() const { return (_Link_type&) this->_M_header._M_right; }

       _Link_type
-      _M_end() const { return (_Link_type) &this->_M_header; }
+      _M_end() const { return static_cast<_Link_type>(const_cast<_Base_ptr>(&this->_M_header) ); }

       static _Link_type&
       _S_left(_Link_type __x) { return (_Link_type&)(__x->_M_left); }


jon

-- 
"Accept the contradictions"
	- The KLF


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]