This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: throw(), pure and const flags on functions
> Hi,
> > I was thinking of this (ABI testsuite breaks). The symbol will
> > disappear from *.so, but since prototype of the function in question was
> > actually never exported from the .cc file itself (i.e. it is not in
> > header), no existing code outside libstdc++ itself should call it, so
> > removing it from exported symbols list should cause no harm?
> >
> Let's not play these risky games. For one we would need to regenerate
> all the baselines for all the targets for the abi check, otherwise make
> check fails. If we can really prove there is something to gain from
> that, let's add for the time being the indirections.
OK, we are losing dynamic linktime performance here, but I guess two
symbols won't make that much difference.
Here is udpated patch, does it look OK now?
Thanks for the pure/const macros, if this is fine, I will submit patch
for those next.
* tree.cc (_Rb_tree_increment, _Rb_tree_decrement,
_Rb_tree_rebalance_for_erase, _Rb_tree_black_count): Mark nothrow;
update uses of _Rb_tree_rotate_left, _Rb_tree_rotate_right.
(_Rb_tree_rotate_left, _Rb_tree_rotate_right): Make wrapper and break
out body to ...
(local_Rb_tree_rotate_left, local_Rb_tree_rotate_right): New static
functions.
* stl_tree.h (_Rb_tree_increment, _Rb_tree_decrement,
_Rb_tree_insert_and_rebalance, _Rb_tree_rebalance_for_erase,
_Rb_tree_black_count): Mark nothrow.
Index: src/tree.cc
===================================================================
--- src/tree.cc (revision 145985)
+++ src/tree.cc (working copy)
@@ -55,7 +55,7 @@
_GLIBCXX_BEGIN_NAMESPACE(std)
_Rb_tree_node_base*
- _Rb_tree_increment(_Rb_tree_node_base* __x)
+ _Rb_tree_increment(_Rb_tree_node_base* __x) throw ()
{
if (__x->_M_right != 0)
{
@@ -78,13 +78,13 @@
}
const _Rb_tree_node_base*
- _Rb_tree_increment(const _Rb_tree_node_base* __x)
+ _Rb_tree_increment(const _Rb_tree_node_base* __x) throw ()
{
return _Rb_tree_increment(const_cast<_Rb_tree_node_base*>(__x));
}
_Rb_tree_node_base*
- _Rb_tree_decrement(_Rb_tree_node_base* __x)
+ _Rb_tree_decrement(_Rb_tree_node_base* __x) throw ()
{
if (__x->_M_color == _S_red
&& __x->_M_parent->_M_parent == __x)
@@ -110,14 +110,14 @@
}
const _Rb_tree_node_base*
- _Rb_tree_decrement(const _Rb_tree_node_base* __x)
+ _Rb_tree_decrement(const _Rb_tree_node_base* __x) throw ()
{
return _Rb_tree_decrement(const_cast<_Rb_tree_node_base*>(__x));
}
- void
- _Rb_tree_rotate_left(_Rb_tree_node_base* const __x,
- _Rb_tree_node_base*& __root)
+ static void
+ local_Rb_tree_rotate_left(_Rb_tree_node_base* const __x,
+ _Rb_tree_node_base*& __root)
{
_Rb_tree_node_base* const __y = __x->_M_right;
@@ -136,10 +136,20 @@
__x->_M_parent = __y;
}
+ /* Static keyword was missing on _Rb_tree_rotate_left.
+ Export the symbol for backward compatibility until
+ next ABI change. */
void
- _Rb_tree_rotate_right(_Rb_tree_node_base* const __x,
- _Rb_tree_node_base*& __root)
+ _Rb_tree_rotate_left(_Rb_tree_node_base* const __x,
+ _Rb_tree_node_base*& __root)
{
+ local_Rb_tree_rotate_left (__x, __root);
+ }
+
+ static void
+ local_Rb_tree_rotate_right(_Rb_tree_node_base* const __x,
+ _Rb_tree_node_base*& __root)
+ {
_Rb_tree_node_base* const __y = __x->_M_left;
__x->_M_left = __y->_M_right;
@@ -157,11 +167,21 @@
__x->_M_parent = __y;
}
+ /* Static keyword was missing on _Rb_tree_rotate_left.
+ Export the symbol for backward compatibility until
+ next ABI change. */
void
+ _Rb_tree_rotate_right(_Rb_tree_node_base* const __x,
+ _Rb_tree_node_base*& __root)
+ {
+ local_Rb_tree_rotate_right (__x, __root);
+ }
+
+ void
_Rb_tree_insert_and_rebalance(const bool __insert_left,
_Rb_tree_node_base* __x,
_Rb_tree_node_base* __p,
- _Rb_tree_node_base& __header)
+ _Rb_tree_node_base& __header) throw ()
{
_Rb_tree_node_base *& __root = __header._M_parent;
@@ -215,11 +235,11 @@
if (__x == __x->_M_parent->_M_right)
{
__x = __x->_M_parent;
- _Rb_tree_rotate_left(__x, __root);
+ local_Rb_tree_rotate_left(__x, __root);
}
__x->_M_parent->_M_color = _S_black;
__xpp->_M_color = _S_red;
- _Rb_tree_rotate_right(__xpp, __root);
+ local_Rb_tree_rotate_right(__xpp, __root);
}
}
else
@@ -237,11 +257,11 @@
if (__x == __x->_M_parent->_M_left)
{
__x = __x->_M_parent;
- _Rb_tree_rotate_right(__x, __root);
+ local_Rb_tree_rotate_right(__x, __root);
}
__x->_M_parent->_M_color = _S_black;
__xpp->_M_color = _S_red;
- _Rb_tree_rotate_left(__xpp, __root);
+ local_Rb_tree_rotate_left(__xpp, __root);
}
}
}
@@ -250,7 +270,7 @@
_Rb_tree_node_base*
_Rb_tree_rebalance_for_erase(_Rb_tree_node_base* const __z,
- _Rb_tree_node_base& __header)
+ _Rb_tree_node_base& __header) throw ()
{
_Rb_tree_node_base *& __root = __header._M_parent;
_Rb_tree_node_base *& __leftmost = __header._M_left;
@@ -337,7 +357,7 @@
{
__w->_M_color = _S_black;
__x_parent->_M_color = _S_red;
- _Rb_tree_rotate_left(__x_parent, __root);
+ local_Rb_tree_rotate_left(__x_parent, __root);
__w = __x_parent->_M_right;
}
if ((__w->_M_left == 0 ||
@@ -356,14 +376,14 @@
{
__w->_M_left->_M_color = _S_black;
__w->_M_color = _S_red;
- _Rb_tree_rotate_right(__w, __root);
+ local_Rb_tree_rotate_right(__w, __root);
__w = __x_parent->_M_right;
}
__w->_M_color = __x_parent->_M_color;
__x_parent->_M_color = _S_black;
if (__w->_M_right)
__w->_M_right->_M_color = _S_black;
- _Rb_tree_rotate_left(__x_parent, __root);
+ local_Rb_tree_rotate_left(__x_parent, __root);
break;
}
}
@@ -375,7 +395,7 @@
{
__w->_M_color = _S_black;
__x_parent->_M_color = _S_red;
- _Rb_tree_rotate_right(__x_parent, __root);
+ local_Rb_tree_rotate_right(__x_parent, __root);
__w = __x_parent->_M_left;
}
if ((__w->_M_right == 0 ||
@@ -393,14 +413,14 @@
{
__w->_M_right->_M_color = _S_black;
__w->_M_color = _S_red;
- _Rb_tree_rotate_left(__w, __root);
+ local_Rb_tree_rotate_left(__w, __root);
__w = __x_parent->_M_left;
}
__w->_M_color = __x_parent->_M_color;
__x_parent->_M_color = _S_black;
if (__w->_M_left)
__w->_M_left->_M_color = _S_black;
- _Rb_tree_rotate_right(__x_parent, __root);
+ local_Rb_tree_rotate_right(__x_parent, __root);
break;
}
}
@@ -411,7 +431,7 @@
unsigned int
_Rb_tree_black_count(const _Rb_tree_node_base* __node,
- const _Rb_tree_node_base* __root)
+ const _Rb_tree_node_base* __root) throw ()
{
if (__node == 0)
return 0;
Index: include/bits/stl_tree.h
===================================================================
--- include/bits/stl_tree.h (revision 145985)
+++ include/bits/stl_tree.h (working copy)
@@ -138,16 +138,16 @@
};
_Rb_tree_node_base*
- _Rb_tree_increment(_Rb_tree_node_base* __x);
+ _Rb_tree_increment(_Rb_tree_node_base* __x) throw ();
const _Rb_tree_node_base*
- _Rb_tree_increment(const _Rb_tree_node_base* __x);
+ _Rb_tree_increment(const _Rb_tree_node_base* __x) throw ();
_Rb_tree_node_base*
- _Rb_tree_decrement(_Rb_tree_node_base* __x);
+ _Rb_tree_decrement(_Rb_tree_node_base* __x) throw ();
const _Rb_tree_node_base*
- _Rb_tree_decrement(const _Rb_tree_node_base* __x);
+ _Rb_tree_decrement(const _Rb_tree_node_base* __x) throw ();
template<typename _Tp>
struct _Rb_tree_iterator
@@ -310,11 +310,11 @@
_Rb_tree_insert_and_rebalance(const bool __insert_left,
_Rb_tree_node_base* __x,
_Rb_tree_node_base* __p,
- _Rb_tree_node_base& __header);
+ _Rb_tree_node_base& __header) throw ();
_Rb_tree_node_base*
_Rb_tree_rebalance_for_erase(_Rb_tree_node_base* const __z,
- _Rb_tree_node_base& __header);
+ _Rb_tree_node_base& __header) throw ();
template<typename _Key, typename _Val, typename _KeyOfValue,
@@ -1450,7 +1450,7 @@
unsigned int
_Rb_tree_black_count(const _Rb_tree_node_base* __node,
- const _Rb_tree_node_base* __root);
+ const _Rb_tree_node_base* __root) throw ();
template<typename _Key, typename _Val, typename _KeyOfValue,
typename _Compare, typename _Alloc>
- References:
- Re: throw(), pure and const flags on functions
- Re: throw(), pure and const flags on functions
- Re: throw(), pure and const flags on functions
- Re: throw(), pure and const flags on functions
- Re: throw(), pure and const flags on functions
- Re: throw(), pure and const flags on functions
- Re: throw(), pure and const flags on functions
- Re: throw(), pure and const flags on functions
- Re: throw(), pure and const flags on functions
- Re: throw(), pure and const flags on functions