+2005-04-28 Paolo Carlini <pcarlini@suse.de>
+ Gabriel Dos Reis <gdr@integrable-solutions.net>
+
+ PR libstdc++/21244 (cont)
+ * include/bits/cpp_type_traits.h (struct __traitor): Convert
+ to bool the values.
+ * include/bits/stl_algo.h: Convert _S_threshold to int.
+ * include/bits/stl_bvector.h: Revert previous change, convert
+ _S_word_bit to int.
+ * include/debug/formatter.h: Convert __max_parameters to
+ size_t.
+ * include/ext/mt_allocator.h: Likewise for _S_chunk_size.
+ * include/ext/pool_allocator.h: Likewise for _S_max_bytes and
+ _S_align.
+ * include/ext/rope: Likewise for _S_alloc_granularity; convert
+ _S_max_rope_depth to int.
+ * include/ext/ropeimpl.h: Convert _S_path_cache_len to int;
+ _S_max_rope_depth to int; _S_copy_max to size_t.
+
2005-04-27 Benjamin Kosnik <bkoz@redhat.com>
* docs/doxygen/user.cfg.in: Update to doxygen-1.4.2.
struct __truth_type<true>
{ typedef __true_type __type; };
+ // N.B. The conversions to bool are needed due to the issue
+ // explained in c++/19404.
template<class _Sp, class _Tp>
struct __traitor
{
- enum { __value = _Sp::__value || _Tp::__value };
+ enum { __value = bool(_Sp::__value) || bool(_Tp::__value) };
typedef typename __truth_type<__value>::__type __type;
};
__final_insertion_sort(_RandomAccessIterator __first,
_RandomAccessIterator __last)
{
- if (__last - __first > _S_threshold)
+ if (__last - __first > int(_S_threshold))
{
- std::__insertion_sort(__first, __first + _S_threshold);
- std::__unguarded_insertion_sort(__first + _S_threshold, __last);
+ std::__insertion_sort(__first, __first + int(_S_threshold));
+ std::__unguarded_insertion_sort(__first + int(_S_threshold), __last);
}
else
std::__insertion_sort(__first, __last);
__final_insertion_sort(_RandomAccessIterator __first,
_RandomAccessIterator __last, _Compare __comp)
{
- if (__last - __first > _S_threshold)
+ if (__last - __first > int(_S_threshold))
{
- std::__insertion_sort(__first, __first + _S_threshold, __comp);
- std::__unguarded_insertion_sort(__first + _S_threshold, __last,
+ std::__insertion_sort(__first, __first + int(_S_threshold), __comp);
+ std::__unguarded_insertion_sort(__first + int(_S_threshold), __last,
__comp);
}
else
typedef typename iterator_traits<_RandomAccessIterator>::value_type
_ValueType;
- while (__last - __first > _S_threshold)
+ while (__last - __first > int(_S_threshold))
{
if (__depth_limit == 0)
{
typedef typename iterator_traits<_RandomAccessIterator>::value_type
_ValueType;
- while (__last - __first > _S_threshold)
+ while (__last - __first > int(_S_threshold))
{
if (__depth_limit == 0)
{
namespace _GLIBCXX_STD
{
typedef unsigned long _Bit_type;
- enum _S_word_bit_enum { _S_word_bit = int(CHAR_BIT * sizeof(_Bit_type)) };
+ enum { _S_word_bit = int(CHAR_BIT * sizeof(_Bit_type)) };
struct _Bit_reference
{
void
_M_bump_up()
{
- if (_M_offset++ == _S_word_bit - 1)
+ if (_M_offset++ == int(_S_word_bit) - 1)
{
_M_offset = 0;
++_M_p;
{
if (_M_offset-- == 0)
{
- _M_offset = _S_word_bit - 1;
+ _M_offset = int(_S_word_bit) - 1;
--_M_p;
}
}
_M_incr(ptrdiff_t __i)
{
difference_type __n = __i + _M_offset;
- _M_p += __n / _S_word_bit;
- __n = __n % _S_word_bit;
+ _M_p += __n / int(_S_word_bit);
+ __n = __n % int(_S_word_bit);
if (__n < 0)
{
- _M_offset = static_cast<unsigned int>(__n + _S_word_bit);
+ _M_offset = static_cast<unsigned int>(__n + int(_S_word_bit));
--_M_p;
}
else
inline ptrdiff_t
operator-(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y)
{
- return _S_word_bit * (__x._M_p - __y._M_p) + __x._M_offset - __y._M_offset;
+ return (int(_S_word_bit) * (__x._M_p - __y._M_p)
+ + __x._M_offset - __y._M_offset);
}
struct _Bit_iterator : public _Bit_iterator_base
_Bit_type*
_M_allocate(size_t __n)
- { return _M_impl.allocate((__n + _S_word_bit - 1) / _S_word_bit); }
+ { return _M_impl.allocate((__n + int(_S_word_bit) - 1)
+ / int(_S_word_bit)); }
void
_M_deallocate()
{
_Bit_type* __q = this->_M_allocate(__n);
this->_M_impl._M_end_of_storage = (__q
- + ((__n + _S_word_bit - 1)
- / _S_word_bit));
+ + ((__n + int(_S_word_bit) - 1)
+ / int(_S_word_bit)));
this->_M_impl._M_start = iterator(__q, 0);
this->_M_impl._M_finish = this->_M_impl._M_start + difference_type(__n);
}
*__i++ = __x;
this->_M_impl._M_finish = std::copy(__position, end(), __i);
this->_M_deallocate();
- this->_M_impl._M_end_of_storage = (__q + ((__len + _S_word_bit - 1)
- / _S_word_bit));
+ this->_M_impl._M_end_of_storage = (__q + ((__len
+ + int(_S_word_bit) - 1)
+ / int(_S_word_bit)));
this->_M_impl._M_start = iterator(__q, 0);
}
}
this->_M_impl._M_finish = std::copy(__position, end(), __i);
this->_M_deallocate();
this->_M_impl._M_end_of_storage = (__q
- + ((__len + _S_word_bit - 1)
- / _S_word_bit));
+ + ((__len
+ + int(_S_word_bit) - 1)
+ / int(_S_word_bit)));
this->_M_impl._M_start = iterator(__q, 0);
}
}
iterator(__q, 0));
this->_M_deallocate();
this->_M_impl._M_start = iterator(__q, 0);
- this->_M_impl._M_end_of_storage = (__q + (__n + _S_word_bit - 1)
- / _S_word_bit);
+ this->_M_impl._M_end_of_storage = (__q + (__n + int(_S_word_bit) - 1)
+ / int(_S_word_bit));
}
}
this->_M_impl._M_finish = std::copy(__position, end(),
__i + difference_type(__n));
this->_M_deallocate();
- this->_M_impl._M_end_of_storage = (__q + ((__len + _S_word_bit - 1)
- / _S_word_bit));
+ this->_M_impl._M_end_of_storage = (__q + ((__len
+ + int(_S_word_bit) - 1)
+ / int(_S_word_bit)));
this->_M_impl._M_start = iterator(__q, 0);
}
}
// Debug-mode error formatting implementation -*- C++ -*-
-// Copyright (C) 2003, 2004
-// Free Software Foundation, Inc.
+// Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
const _Error_formatter&
_M_iterator(const _Iterator& __it, const char* __name = 0) const
{
- if (_M_num_parameters < __max_parameters)
+ if (_M_num_parameters < size_t(__max_parameters))
_M_parameters[_M_num_parameters++] = _Parameter(__it, __name,
_Is_iterator());
return *this;
const _Error_formatter&
_M_integer(long __value, const char* __name = 0) const
{
- if (_M_num_parameters < __max_parameters)
+ if (_M_num_parameters < size_t(__max_parameters))
_M_parameters[_M_num_parameters++] = _Parameter(__value, __name);
return *this;
}
const _Error_formatter&
_M_string(const char* __value, const char* __name = 0) const
{
- if (_M_num_parameters < __max_parameters)
+ if (_M_num_parameters < size_t(__max_parameters))
_M_parameters[_M_num_parameters++] = _Parameter(__value, __name);
return *this;
}
const _Error_formatter&
_M_sequence(const _Sequence& __seq, const char* __name = 0) const
{
- if (_M_num_parameters < __max_parameters)
+ if (_M_num_parameters < size_t(__max_parameters))
_M_parameters[_M_num_parameters++] = _Parameter(__seq, __name,
_Is_sequence());
return *this;
static _Tune _S_tune(__align, sizeof(_Tp) * 64,
sizeof(_Tp) * 2 >= __align ? sizeof(_Tp) * 2
: __align,
- sizeof(_Tp) * _Tune::_S_chunk_size,
+ sizeof(_Tp) * size_t(_Tune::_S_chunk_size),
_Tune::_S_max_threads,
_Tune::_S_freelist_headroom,
getenv("GLIBCXX_FORCE_NEW") ? true : false);
static _Tune _S_tune(__align, sizeof(_Tp) * 64,
sizeof(_Tp) * 2 >= __align ? sizeof(_Tp) * 2
: __align,
- sizeof(_Tp) * _Tune::_S_chunk_size,
+ sizeof(_Tp) * size_t(_Tune::_S_chunk_size),
_Tune::_S_max_threads,
_Tune::_S_freelist_headroom,
getenv("GLIBCXX_FORCE_NEW") ? true : false);
enum { _S_align = 8 };
enum { _S_max_bytes = 128 };
- enum { _S_free_list_size = _S_max_bytes / _S_align };
+ enum { _S_free_list_size = (size_t)_S_max_bytes / (size_t)_S_align };
union _Obj
{
return __size_with_eos;
#else
// Allow slop for in-place expansion.
- return ((__size_with_eos + _S_alloc_granularity - 1)
- &~ (_S_alloc_granularity - 1));
+ return ((__size_with_eos + size_t(_S_alloc_granularity) - 1)
+ &~ (size_t(_S_alloc_granularity) - 1));
#endif
}
__GC_CONST _CharT* _M_data; /* Not necessarily 0 terminated. */
size_type
max_size() const
{
- return _S_min_len[_Rope_constants::_S_max_rope_depth - 1] - 1;
+ return _S_min_len[int(_Rope_constants::_S_max_rope_depth) - 1] - 1;
// Guarantees that the result can be sufficirntly
// balanced. Longer ropes will probably still work,
// but it's harder to make guarantees.
_Rope_iterator_base<_CharT, _Alloc>::
_S_setcache(_Rope_iterator_base<_CharT, _Alloc>& __x)
{
- const _RopeRep* __path[_Rope_constants::_S_max_rope_depth + 1];
+ const _RopeRep* __path[int(_Rope_constants::_S_max_rope_depth) + 1];
const _RopeRep* __curr_rope;
int __curr_depth = -1; /* index into path */
size_t __curr_start_pos = 0;
// Copy last section of path into _M_path_end.
{
int __i = -1;
- int __j = __curr_depth + 1 - _S_path_cache_len;
+ int __j = __curr_depth + 1 - int(_S_path_cache_len);
if (__j < 0) __j = 0;
while (__j <= __curr_depth)
while (_Rope_constants::_S_concat == __current_node->_M_tag)
{
++__current_index;
- if (_S_path_cache_len == __current_index)
+ if (int(_S_path_cache_len) == __current_index)
{
int __i;
- for (__i = 0; __i < _S_path_cache_len-1; __i++)
+ for (__i = 0; __i < int(_S_path_cache_len) - 1; __i++)
__x._M_path_end[__i] = __x._M_path_end[__i+1];
--__current_index;
}
get_allocator());
size_t __depth = __result->_M_depth;
- if (__depth > 20 && (__result->_M_size < 1000
- || __depth > _Rope_constants::_S_max_rope_depth))
+ if (__depth > 20
+ && (__result->_M_size < 1000
+ || __depth > size_t(_Rope_constants::_S_max_rope_depth)))
{
_RopeRep* __balanced;
return __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __slen,
__r->get_allocator());
if (_Rope_constants::_S_leaf == __r->_M_tag
- && __r->_M_size + __slen <= _S_copy_max)
+ && __r->_M_size + __slen <= size_t(_S_copy_max))
{
__result = _S_leaf_concat_char_iter((_RopeLeaf*)__r, __s, __slen);
return __result;
{
_RopeLeaf* __right =
(_RopeLeaf* )(((_RopeConcatenation* )__r)->_M_right);
- if (__right->_M_size + __slen <= _S_copy_max)
+ if (__right->_M_size + __slen <= size_t(_S_copy_max))
{
_RopeRep* __left = ((_RopeConcatenation*)__r)->_M_left;
_RopeRep* __nright =
__r->_M_ref_count = 2; // One more than before
return __r;
}
- if (__orig_size + __slen <= _S_copy_max
+ if (__orig_size + __slen <= size_t(_S_copy_max)
&& _Rope_constants::_S_leaf == __r->_M_tag)
{
__result = _S_destr_leaf_concat_char_iter((_RopeLeaf*)__r, __s,
_RopeLeaf* __right = (_RopeLeaf*)(((_RopeConcatenation*)
__r)->_M_right);
if (_Rope_constants::_S_leaf == __right->_M_tag
- && __right->_M_size + __slen <= _S_copy_max)
+ && __right->_M_size + __slen <= size_t(_S_copy_max))
{
_RopeRep* __new_right =
_S_destr_leaf_concat_char_iter(__right, __s, __slen);
{
if (_Rope_constants::_S_leaf == __left->_M_tag)
{
- if (__right->_M_size + __left->_M_size <= _S_copy_max)
+ if (__right->_M_size + __left->_M_size <= size_t(_S_copy_max))
return _S_leaf_concat_char_iter((_RopeLeaf*)__left,
((_RopeLeaf*)__right)->_M_data,
__right->_M_size);
{
_RopeLeaf* __leftright =
(_RopeLeaf*)(((_RopeConcatenation*)__left)->_M_right);
- if (__leftright->_M_size + __right->_M_size <= _S_copy_max)
+ if (__leftright->_M_size
+ + __right->_M_size <= size_t(_S_copy_max))
{
_RopeRep* __leftleft = ((_RopeConcatenation*)__left)->_M_left;
_RopeRep* __rest = _S_leaf_concat_char_iter(__leftright,
template <class _CharT, class _Alloc>
const unsigned long
rope<_CharT, _Alloc>::
- _S_min_len[_Rope_constants::_S_max_rope_depth + 1] = {
+ _S_min_len[int(_Rope_constants::_S_max_rope_depth) + 1] = {
/* 0 */1, /* 1 */2, /* 2 */3, /* 3 */5, /* 4 */8, /* 5 */13, /* 6 */21,
/* 7 */34, /* 8 */55, /* 9 */89, /* 10 */144, /* 11 */233, /* 12 */377,
/* 13 */610, /* 14 */987, /* 15 */1597, /* 16 */2584, /* 17 */4181,
rope<_CharT, _Alloc>::
_S_balance(_RopeRep* __r)
{
- _RopeRep* __forest[_Rope_constants::_S_max_rope_depth + 1];
+ _RopeRep* __forest[int(_Rope_constants::_S_max_rope_depth) + 1];
_RopeRep* __result = 0;
int __i;
// Invariant:
// __forest[__i]._M_depth = __i
// References from forest are included in refcount.
- for (__i = 0; __i <= _Rope_constants::_S_max_rope_depth; ++__i)
+ for (__i = 0; __i <= int(_Rope_constants::_S_max_rope_depth); ++__i)
__forest[__i] = 0;
try
{
_S_add_to_forest(__r, __forest);
- for (__i = 0; __i <= _Rope_constants::_S_max_rope_depth; ++__i)
+ for (__i = 0; __i <= int(_Rope_constants::_S_max_rope_depth); ++__i)
if (0 != __forest[__i])
{
#ifndef __GC
}
catch(...)
{
- for(__i = 0; __i <= _Rope_constants::_S_max_rope_depth; __i++)
+ for(__i = 0; __i <= int(_Rope_constants::_S_max_rope_depth); __i++)
_S_unref(__forest[__i]);
__throw_exception_again;
}
- if (__result->_M_depth > _Rope_constants::_S_max_rope_depth)
+ if (__result->_M_depth > int(_Rope_constants::_S_max_rope_depth))
__throw_length_error(__N("rope::_S_balance"));
return(__result);
}
__forest[__i]->_M_unref_nonnil();
__forest[__i] = 0;
}
- if (__i == _Rope_constants::_S_max_rope_depth
+ if (__i == int(_Rope_constants::_S_max_rope_depth)
|| __insertee->_M_size < _S_min_len[__i+1])
{
__forest[__i] = __insertee;