This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
V3 PATCH: Avoid comparaison between signed and unsigned integers types
- To: libstdc++ at sourceware dot cygnus dot com
- Subject: V3 PATCH: Avoid comparaison between signed and unsigned integers types
- From: Gabriel Dos Reis <Gabriel dot Dos-Reis at cmla dot ens-cachan dot fr>
- Date: 12 Feb 2001 01:27:18 +0100
- Organization: CMLA, ENS Cachan -- CNRS UMR 8536 (France)
This fixes prs libstdc++/555. I take the opportunity to reformat
surrounding codes.
-- Gaby
2001-02-11 Gabriel Dos Reis <gdr@codesourcery.com>
* include/bits/std_valarray.h(valarray<>::shift): Avoid
comparaison between signed and unsigned integer types.
(valarray<>::cshift): Reformat.
Index: include/bits/std_valarray.h
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/include/bits/std_valarray.h,v
retrieving revision 1.2
diff -p -r1.2 std_valarray.h
*** std_valarray.h 2000/10/26 08:49:10 1.2
--- std_valarray.h 2001/02/11 22:16:04
*************** namespace std {
*** 472,519 ****
// }
template <class _Tp>
! inline valarray<_Tp>
! valarray<_Tp>::shift (int __n) const
! {
! _Tp* const __a = static_cast<_Tp*>
! (__builtin_alloca (sizeof(_Tp) * _M_size));
! if (! __n) // __n == 0: no shift
! __valarray_copy_construct(_M_data, _M_data + _M_size, __a);
! else if (__n > 0) { // __n > 0: shift left
! if (__n > _M_size)
! __valarray_default_construct(__a, __a + __n);
! else {
! __valarray_copy_construct(_M_data+__n, _M_data + _M_size, __a);
! __valarray_default_construct(__a+_M_size-__n, __a + _M_size);
! }
! }
! else { // __n < 0: shift right
! __valarray_copy_construct (_M_data, _M_data+_M_size+__n, __a-__n);
! __valarray_default_construct(__a, __a - __n);
! }
! return valarray<_Tp> (__a, _M_size);
! }
template <class _Tp>
! inline valarray<_Tp>
! valarray<_Tp>::cshift (int __n) const
! {
! _Tp* const __a = static_cast<_Tp*>
! (__builtin_alloca (sizeof(_Tp) * _M_size));
! if (! __n) // __n == 0: no cshift
! __valarray_copy_construct(_M_data, _M_data + _M_size, __a);
! else if (__n > 0) { // __n > 0: cshift left
! __valarray_copy_construct(_M_data, _M_data+__n, __a+_M_size-__n);
! __valarray_copy_construct(_M_data+__n, _M_data + _M_size, __a);
! }
! else { // __n < 0: cshift right
! __valarray_copy_construct
! (_M_data + _M_size+__n, _M_data + _M_size, __a);
! __valarray_copy_construct
! (_M_data, _M_data + _M_size+__n, __a - __n);
! }
! return valarray<_Tp> (__a, _M_size);
! }
template <class _Tp>
inline void
--- 472,524 ----
// }
template <class _Tp>
! inline valarray<_Tp>
! valarray<_Tp>::shift(int __n) const
! {
! _Tp* const __a = static_cast<_Tp*>
! (__builtin_alloca(sizeof(_Tp) * _M_size));
! if (__n == 0) // no shift
! __valarray_copy_construct(_M_data, _M_data + _M_size, __a);
! else if (__n > 0) // __n > 0: shift left
! {
! if (size_t(__n) > _M_size)
! __valarray_default_construct(__a, __a + __n);
! else
! {
! __valarray_copy_construct(_M_data+__n, _M_data + _M_size, __a);
! __valarray_default_construct(__a+_M_size-__n, __a + _M_size);
! }
! }
! else // __n < 0: shift right
! {
! __valarray_copy_construct (_M_data, _M_data+_M_size+__n, __a-__n);
! __valarray_default_construct(__a, __a - __n);
! }
! return valarray<_Tp> (__a, _M_size);
! }
template <class _Tp>
! inline valarray<_Tp>
! valarray<_Tp>::cshift (int __n) const
! {
! _Tp* const __a = static_cast<_Tp*>
! (__builtin_alloca (sizeof(_Tp) * _M_size));
! if (__n == 0) // no cshift
! __valarray_copy_construct(_M_data, _M_data + _M_size, __a);
! else if (__n > 0) // cshift left
! {
! __valarray_copy_construct(_M_data, _M_data+__n, __a+_M_size-__n);
! __valarray_copy_construct(_M_data+__n, _M_data + _M_size, __a);
! }
! else // cshift right
! {
! __valarray_copy_construct
! (_M_data + _M_size+__n, _M_data + _M_size, __a);
! __valarray_copy_construct
! (_M_data, _M_data + _M_size+__n, __a - __n);
! }
! return valarray<_Tp>(__a, _M_size);
! }
template <class _Tp>
inline void