PR libstdc++/21244 (cont)

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.

Co-Authored-By: Gabriel Dos Reis <gdr@integrable-solutions.net>

From-SVN: r98915
This commit is contained in:
Paolo Carlini 2005-04-28 07:50:48 +00:00 committed by Paolo Carlini
parent fe9565ed02
commit a9dd5a466a
9 changed files with 85 additions and 58 deletions

View File

@ -1,3 +1,22 @@
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.

View File

@ -103,10 +103,12 @@ namespace std
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;
};

View File

@ -2212,10 +2212,10 @@ namespace std
__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);
@ -2231,10 +2231,10 @@ namespace std
__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
@ -2481,7 +2481,7 @@ namespace std
typedef typename iterator_traits<_RandomAccessIterator>::value_type
_ValueType;
while (__last - __first > _S_threshold)
while (__last - __first > int(_S_threshold))
{
if (__depth_limit == 0)
{
@ -2517,7 +2517,7 @@ namespace std
typedef typename iterator_traits<_RandomAccessIterator>::value_type
_ValueType;
while (__last - __first > _S_threshold)
while (__last - __first > int(_S_threshold))
{
if (__depth_limit == 0)
{

View File

@ -64,7 +64,7 @@
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
{
@ -117,7 +117,7 @@ namespace _GLIBCXX_STD
void
_M_bump_up()
{
if (_M_offset++ == _S_word_bit - 1)
if (_M_offset++ == int(_S_word_bit) - 1)
{
_M_offset = 0;
++_M_p;
@ -129,7 +129,7 @@ namespace _GLIBCXX_STD
{
if (_M_offset-- == 0)
{
_M_offset = _S_word_bit - 1;
_M_offset = int(_S_word_bit) - 1;
--_M_p;
}
}
@ -138,11 +138,11 @@ namespace _GLIBCXX_STD
_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
@ -180,7 +180,8 @@ namespace _GLIBCXX_STD
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
@ -384,7 +385,8 @@ namespace _GLIBCXX_STD
_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()
@ -452,8 +454,8 @@ template<typename _Alloc>
{
_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);
}
@ -477,8 +479,9 @@ template<typename _Alloc>
*__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);
}
}
@ -543,8 +546,9 @@ template<typename _Alloc>
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);
}
}
@ -782,8 +786,8 @@ template<typename _Alloc>
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));
}
}
@ -888,8 +892,9 @@ template<typename _Alloc>
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);
}
}

View File

@ -1,7 +1,6 @@
// 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
@ -310,7 +309,7 @@ namespace __gnu_debug
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;
@ -319,7 +318,7 @@ namespace __gnu_debug
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;
}
@ -327,7 +326,7 @@ namespace __gnu_debug
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;
}
@ -336,7 +335,7 @@ namespace __gnu_debug
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;

View File

@ -503,7 +503,7 @@ namespace __gnu_cxx
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);
@ -549,7 +549,7 @@ namespace __gnu_cxx
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);

View File

@ -80,7 +80,7 @@ namespace __gnu_cxx
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
{

View File

@ -676,8 +676,8 @@ protected:
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. */
@ -1998,7 +1998,7 @@ protected:
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.

View File

@ -116,7 +116,7 @@ namespace __gnu_cxx
_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;
@ -175,7 +175,7 @@ namespace __gnu_cxx
// 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)
@ -236,10 +236,10 @@ namespace __gnu_cxx
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;
}
@ -500,8 +500,9 @@ namespace __gnu_cxx
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;
@ -540,7 +541,7 @@ namespace __gnu_cxx
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;
@ -551,7 +552,7 @@ namespace __gnu_cxx
{
_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 =
@ -603,7 +604,7 @@ namespace __gnu_cxx
__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,
@ -615,7 +616,7 @@ namespace __gnu_cxx
_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);
@ -668,7 +669,7 @@ namespace __gnu_cxx
{
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);
@ -679,7 +680,8 @@ namespace __gnu_cxx
{
_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,
@ -1184,7 +1186,7 @@ namespace __gnu_cxx
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,
@ -1203,7 +1205,7 @@ namespace __gnu_cxx
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:
@ -1212,12 +1214,12 @@ namespace __gnu_cxx
// __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
@ -1232,12 +1234,12 @@ namespace __gnu_cxx
}
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);
}
@ -1305,7 +1307,7 @@ namespace __gnu_cxx
__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;