Commit 226a2e08 by Paolo Carlini Committed by Paolo Carlini

locale_facets.tcc (num_get<>::do_get(iter_type, iter_type, ios_base&,…

locale_facets.tcc (num_get<>::do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, bool&), [...]): -Wconversion and -Woverflow fixes.

2007-01-28  Paolo Carlini  <pcarlini@suse.de>

	* include/bits/locale_facets.tcc (num_get<>::do_get(iter_type,
	iter_type, ios_base&, ios_base::iostate&, bool&),
	num_put<>::_M_insert_int(_OutIter, ios_base&, _CharT, _ValueT)):
	-Wconversion and -Woverflow fixes.
	* include/bits/istream.tcc (operator>>(int&), operator>>(short&)):
	Likewise.
	* include/std/valarray (valarray<>::shift, cshift): Likewise.

From-SVN: r121264
parent 5cf10afb
2007-01-28 Paolo Carlini <pcarlini@suse.de>
* include/bits/locale_facets.tcc (num_get<>::do_get(iter_type,
iter_type, ios_base&, ios_base::iostate&, bool&),
num_put<>::_M_insert_int(_OutIter, ios_base&, _CharT, _ValueT)):
-Wconversion and -Woverflow fixes.
* include/bits/istream.tcc (operator>>(int&), operator>>(short&)):
Likewise.
* include/std/valarray (valarray<>::shift, cshift): Likewise.
2007-01-26 Paolo Carlini <pcarlini@suse.de> 2007-01-26 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/30586 PR libstdc++/30586
......
// istream classes -*- C++ -*- // istream classes -*- C++ -*-
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
// 2006, 2007
// Free Software Foundation, Inc. // Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
...@@ -121,7 +122,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -121,7 +122,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{ {
if (numeric_limits<short>::min() <= __l if (numeric_limits<short>::min() <= __l
&& __l <= numeric_limits<short>::max()) && __l <= numeric_limits<short>::max())
__n = __l; __n = short(__l);
else else
this->setstate(ios_base::failbit); this->setstate(ios_base::failbit);
} }
...@@ -141,7 +142,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -141,7 +142,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{ {
if (numeric_limits<int>::min() <= __l if (numeric_limits<int>::min() <= __l
&& __l <= numeric_limits<int>::max()) && __l <= numeric_limits<int>::max())
__n = __l; __n = int(__l);
else else
this->setstate(ios_base::failbit); this->setstate(ios_base::failbit);
} }
......
...@@ -725,7 +725,7 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE ...@@ -725,7 +725,7 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE
long __l = -1; long __l = -1;
__beg = _M_extract_int(__beg, __end, __io, __err, __l); __beg = _M_extract_int(__beg, __end, __io, __err, __l);
if (__l == 0 || __l == 1) if (__l == 0 || __l == 1)
__v = __l; __v = bool(__l);
else else
__err |= ios_base::failbit; __err |= ios_base::failbit;
} }
...@@ -764,9 +764,9 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE ...@@ -764,9 +764,9 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE
__testeof = true; __testeof = true;
} }
if (__testf && __n == __lc->_M_falsename_size) if (__testf && __n == __lc->_M_falsename_size)
__v = 0; __v = false;
else if (__testt && __n == __lc->_M_truename_size) else if (__testt && __n == __lc->_M_truename_size)
__v = 1; __v = true;
else else
__err |= ios_base::failbit; __err |= ios_base::failbit;
...@@ -994,7 +994,9 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE ...@@ -994,7 +994,9 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE
const ios_base::fmtflags __basefield = __flags & ios_base::basefield; const ios_base::fmtflags __basefield = __flags & ios_base::basefield;
const bool __dec = (__basefield != ios_base::oct const bool __dec = (__basefield != ios_base::oct
&& __basefield != ios_base::hex); && __basefield != ios_base::hex);
const __unsigned_type __u = (__v > 0 || !__dec) ? __v : -__v; const __unsigned_type __u = ((__v > 0 || !__dec)
? __unsigned_type(__v)
: -__unsigned_type(__v));
int __len = __int_to_char(__cs + __ilen, __u, __lit, __flags, __dec); int __len = __int_to_char(__cs + __ilen, __u, __lit, __flags, __dec);
__cs += __ilen - __len; __cs += __ilen - __len;
......
...@@ -796,7 +796,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -796,7 +796,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
else if (__n > 0) // shift left else if (__n > 0) // shift left
{ {
if (size_t(__n) > _M_size) if (size_t(__n) > _M_size)
__n = _M_size; __n = int(_M_size);
std::__valarray_copy_construct(_M_data + __n, std::__valarray_copy_construct(_M_data + __n,
_M_data + _M_size, __tmp_M_data); _M_data + _M_size, __tmp_M_data);
...@@ -805,8 +805,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -805,8 +805,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
} }
else // shift right else // shift right
{ {
if (size_t(-__n) > _M_size) if (-size_t(__n) > _M_size)
__n = -_M_size; __n = -int(_M_size);
std::__valarray_copy_construct(_M_data, _M_data + _M_size + __n, std::__valarray_copy_construct(_M_data, _M_data + _M_size + __n,
__tmp_M_data - __n); __tmp_M_data - __n);
...@@ -837,7 +837,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -837,7 +837,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
else if (__n > 0) // cshift left else if (__n > 0) // cshift left
{ {
if (size_t(__n) > _M_size) if (size_t(__n) > _M_size)
__n = __n % _M_size; __n = int(__n % _M_size);
std::__valarray_copy_construct(_M_data, _M_data + __n, std::__valarray_copy_construct(_M_data, _M_data + __n,
__tmp_M_data + _M_size - __n); __tmp_M_data + _M_size - __n);
...@@ -846,8 +846,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -846,8 +846,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
} }
else // cshift right else // cshift right
{ {
if (size_t(-__n) > _M_size) if (-size_t(__n) > _M_size)
__n = -(size_t(-__n) % _M_size); __n = -int(-size_t(__n) % _M_size);
std::__valarray_copy_construct(_M_data + _M_size + __n, std::__valarray_copy_construct(_M_data + _M_size + __n,
_M_data + _M_size, __tmp_M_data); _M_data + _M_size, __tmp_M_data);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment