* [v3] Fix libstdc++/32422 (+ DR 23)
@ 2008-09-23 8:13 Paolo Carlini
2008-10-01 23:02 ` Andrew Pinski
0 siblings, 1 reply; 3+ messages in thread
From: Paolo Carlini @ 2008-09-23 8:13 UTC (permalink / raw)
To: Gcc Patch List; +Cc: libstdc++
[-- Attachment #1: Type: text/plain, Size: 114 bytes --]
Hi,
tested x86_64-linux multilib, gnu/generic locale models, committed to
mainline.
Paolo.
///////////////////
[-- Attachment #2: CL_32422_dr23 --]
[-- Type: text/plain, Size: 2381 bytes --]
2008-09-23 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/32422, DR 23 [Ready in R60]
* config/locale/gnu/c_locale.cc (__convert_to_v(const char*, float&,
ios_base::iostate&, const __c_locale&), __convert_to_v(const char*,
double&, ios_base::iostate&, const __c_locale&), __convert_to_v(const
char*, long double&, ios_base::iostate&, const __c_locale&)): Implement
DR 23 and deal correctly with broken exponents.
* config/locale/generic/c_locale.cc (__convert_to_v(const char*,
float&, ios_base::iostate&, const __c_locale&), __convert_to_v(const
char*, double&, ios_base::iostate&, const __c_locale&),
__convert_to_v(const char*, long double&, ios_base::iostate&, const
__c_locale&)): Likewise.
* include/bits/locale_facets.tcc (num_get<>::_M_extract_int(_InIter,
_InIter, ios_base&, ios_base::iostate&, _ValueT&)): Likewise.
(num_get<>::_M_extract_float(_InIter, _InIter, ios_base&,
ios_base::iostate&, string&): Change grouping check to set instead of
OR failbit; do not check for eofbit here...
(num_get<>::do_get(iter_type, iter_type, ios_base&,
ios_base::iostate&, float&), num_get<>::do_get(iter_type, iter_type,
ios_base&, ios_base::iostate&, double&), num_get<>::do_get(iter_type,
iter_type, ios_base&, ios_base::iostate&, long double&),
num_get<>::__do_get(iter_type, iter_type, ios_base&,
ios_base::iostate&, double&)): ... do it here instead.
(num_get<>::do_get(iter_type, iter_type, ios_base&,
ios_base::iostate&, bool&)): Implement DR 23.
(num_get<>::do_get(iter_type, iter_type, ios_base&,
ios_base::iostate&, void*&)): Adjust.
* doc/xml/manual/intro.xml: Add and entry for DR 23.
* testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/10.cc:
Adjust.
* testsuite/27_io/basic_istream/extractors_arithmetic/char/10.cc:
Likewise.
* testsuite/22_locale/num_get/get/wchar_t/22131.cc: Likewise.
* testsuite/22_locale/num_get/get/wchar_t/10.cc: Likewise.
* testsuite/22_locale/num_get/get/wchar_t/12.cc: Likewise.
* testsuite/22_locale/num_get/get/wchar_t/15.cc: Likewise.
* testsuite/22_locale/num_get/get/wchar_t/16.cc: Likewise.
* testsuite/22_locale/num_get/get/char/22131.cc: Likewise.
* testsuite/22_locale/num_get/get/char/10.cc: Likewise.
* testsuite/22_locale/num_get/get/char/12.cc: Likewise.
* testsuite/22_locale/num_get/get/char/15.cc: Likewise.
* testsuite/22_locale/num_get/get/char/16.cc: Likewise.
[-- Attachment #3: patch_32422_dr23 --]
[-- Type: text/plain, Size: 44315 bytes --]
Index: doc/xml/manual/intro.xml
===================================================================
*** doc/xml/manual/intro.xml (revision 140573)
--- doc/xml/manual/intro.xml (working copy)
***************
*** 192,197 ****
--- 192,203 ----
<listitem><para>Re-opening a file stream does <emphasis>not</emphasis> clear the state flags.
</para></listitem></varlistentry>
+ <varlistentry><term><ulink url="../ext/lwg-active.html#23">23</ulink>:
+ <emphasis>Num_get overflow result</emphasis>
+ </term>
+ <listitem><para>Implement the proposed resolution.
+ </para></listitem></varlistentry>
+
<varlistentry><term><ulink url="../ext/lwg-defects.html#25">25</ulink>:
<emphasis>String operator<< uses width() value wrong</emphasis>
</term>
Index: include/bits/locale_facets.tcc
===================================================================
*** include/bits/locale_facets.tcc (revision 140573)
--- include/bits/locale_facets.tcc (working copy)
*************** _GLIBCXX_BEGIN_LDBL_NAMESPACE
*** 345,356 ****
if (!std::__verify_grouping(__lc->_M_grouping,
__lc->_M_grouping_size,
__found_grouping))
! __err |= ios_base::failbit;
}
- // Finish up.
- if (__testeof)
- __err |= ios_base::eofbit;
return __beg;
}
--- 345,353 ----
if (!std::__verify_grouping(__lc->_M_grouping,
__lc->_M_grouping_size,
__found_grouping))
! __err = ios_base::failbit;
}
return __beg;
}
*************** _GLIBCXX_BEGIN_LDBL_NAMESPACE
*** 454,459 ****
--- 451,457 ----
if (__lc->_M_use_grouping)
__found_grouping.reserve(32);
bool __testfail = false;
+ bool __testoverflow = false;
const __unsigned_type __max = __negative
? -__gnu_cxx::__numeric_traits<_ValueT>::__min
: __gnu_cxx::__numeric_traits<_ValueT>::__max;
*************** _GLIBCXX_BEGIN_LDBL_NAMESPACE
*** 471,481 ****
break;
if (__result > __smax)
! __testfail = true;
else
{
__result *= __base;
! __testfail |= __result > __max - __digit;
__result += __digit;
++__sep_pos;
}
--- 469,479 ----
break;
if (__result > __smax)
! __testoverflow = true;
else
{
__result *= __base;
! __testoverflow |= __result > __max - __digit;
__result += __digit;
++__sep_pos;
}
*************** _GLIBCXX_BEGIN_LDBL_NAMESPACE
*** 518,528 ****
if (__digit > 15)
__digit -= 6;
if (__result > __smax)
! __testfail = true;
else
{
__result *= __base;
! __testfail |= __result > __max - __digit;
__result += __digit;
++__sep_pos;
}
--- 516,526 ----
if (__digit > 15)
__digit -= 6;
if (__result > __smax)
! __testoverflow = true;
else
{
__result *= __base;
! __testoverflow |= __result > __max - __digit;
__result += __digit;
++__sep_pos;
}
*************** _GLIBCXX_BEGIN_LDBL_NAMESPACE
*** 544,557 ****
if (!std::__verify_grouping(__lc->_M_grouping,
__lc->_M_grouping_size,
__found_grouping))
! __err |= ios_base::failbit;
}
! if (!__testfail && (__sep_pos || __found_zero
! || __found_grouping.size()))
! __v = __negative ? -__result : __result;
else
! __err |= ios_base::failbit;
if (__testeof)
__err |= ios_base::eofbit;
--- 542,568 ----
if (!std::__verify_grouping(__lc->_M_grouping,
__lc->_M_grouping_size,
__found_grouping))
! __err = ios_base::failbit;
}
! // _GLIBCXX_RESOLVE_LIB_DEFECTS
! // 23. Num_get overflow result.
! if ((!__sep_pos && !__found_zero && !__found_grouping.size())
! || __testfail)
! {
! __v = 0;
! __err = ios_base::failbit;
! }
! else if (__testoverflow)
! {
! if (__negative)
! __v = __gnu_cxx::__numeric_traits<_ValueT>::__min;
! else
! __v = __gnu_cxx::__numeric_traits<_ValueT>::__max;
! __err = ios_base::failbit;
! }
else
! __v = __negative ? -__result : __result;
if (__testeof)
__err |= ios_base::eofbit;
*************** _GLIBCXX_BEGIN_LDBL_NAMESPACE
*** 576,582 ****
if (__l == 0 || __l == 1)
__v = bool(__l);
else
! __err |= ios_base::failbit;
}
else
{
--- 587,600 ----
if (__l == 0 || __l == 1)
__v = bool(__l);
else
! {
! // _GLIBCXX_RESOLVE_LIB_DEFECTS
! // 23. Num_get overflow result.
! __v = true;
! __err = ios_base::failbit;
! if (__beg == __end)
! __err |= ios_base::eofbit;
! }
}
else
{
*************** _GLIBCXX_BEGIN_LDBL_NAMESPACE
*** 621,627 ****
else if (__testt && __n == __lc->_M_truename_size)
__v = true;
else
! __err |= ios_base::failbit;
if (__testeof)
__err |= ios_base::eofbit;
--- 639,650 ----
else if (__testt && __n == __lc->_M_truename_size)
__v = true;
else
! {
! // _GLIBCXX_RESOLVE_LIB_DEFECTS
! // 23. Num_get overflow result.
! __v = false;
! __err = ios_base::failbit;
! }
if (__testeof)
__err |= ios_base::eofbit;
*************** _GLIBCXX_BEGIN_LDBL_NAMESPACE
*** 683,688 ****
--- 706,713 ----
__xtrc.reserve(32);
__beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale());
+ if (__beg == __end)
+ __err |= ios_base::eofbit;
return __beg;
}
*************** _GLIBCXX_BEGIN_LDBL_NAMESPACE
*** 696,701 ****
--- 721,728 ----
__xtrc.reserve(32);
__beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale());
+ if (__beg == __end)
+ __err |= ios_base::eofbit;
return __beg;
}
*************** _GLIBCXX_BEGIN_LDBL_NAMESPACE
*** 710,715 ****
--- 737,744 ----
__xtrc.reserve(32);
__beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale());
+ if (__beg == __end)
+ __err |= ios_base::eofbit;
return __beg;
}
#endif
*************** _GLIBCXX_BEGIN_LDBL_NAMESPACE
*** 724,729 ****
--- 753,760 ----
__xtrc.reserve(32);
__beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale());
+ if (__beg == __end)
+ __err |= ios_base::eofbit;
return __beg;
}
*************** _GLIBCXX_BEGIN_LDBL_NAMESPACE
*** 748,755 ****
// Reset from hex formatted input.
__io.flags(__fmt);
! if (!(__err & ios_base::failbit))
! __v = reinterpret_cast<void*>(__ul);
return __beg;
}
--- 779,785 ----
// Reset from hex formatted input.
__io.flags(__fmt);
! __v = reinterpret_cast<void*>(__ul);
return __beg;
}
Index: testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/10.cc
===================================================================
*** testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/10.cc (revision 140573)
--- testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/10.cc (working copy)
***************
*** 1,4 ****
! // Copyright (C) 2004 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
--- 1,4 ----
! // Copyright (C) 2004, 2005, 2006, 2007, 2008 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
*************** bool test10()
*** 107,120 ****
is_05 >> f;
VERIFY( f == 0 );
is_05 >> f;
! VERIFY( f == 5.0 );
! VERIFY( is_05.rdstate() == std::ios_base::goodbit );
is_05.clear();
is_05 >> c;
VERIFY( c == L'a' );
is_05 >> f;
! VERIFY( f == 5.0 );
VERIFY( is_05.rdstate() == std::ios_base::failbit );
is_05.clear();
is_05.ignore();
--- 107,122 ----
is_05 >> f;
VERIFY( f == 0 );
+ f = 1;
is_05 >> f;
! VERIFY( f == 0 );
! VERIFY( is_05.rdstate() == std::ios_base::failbit );
is_05.clear();
is_05 >> c;
VERIFY( c == L'a' );
+ f = 1;
is_05 >> f;
! VERIFY( f == 0 );
VERIFY( is_05.rdstate() == std::ios_base::failbit );
is_05.clear();
is_05.ignore();
Index: testsuite/27_io/basic_istream/extractors_arithmetic/char/10.cc
===================================================================
*** testsuite/27_io/basic_istream/extractors_arithmetic/char/10.cc (revision 140573)
--- testsuite/27_io/basic_istream/extractors_arithmetic/char/10.cc (working copy)
***************
*** 1,6 ****
// 1999-04-12 bkoz
! // Copyright (C) 1999, 2000, 2002, 2003 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
--- 1,7 ----
// 1999-04-12 bkoz
! // Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
! // 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
*************** bool test10()
*** 109,122 ****
is_05 >> f;
VERIFY( f == 0 );
is_05 >> f;
! VERIFY( f == 5.0 );
! VERIFY( is_05.rdstate() == std::ios_base::goodbit );
is_05.clear();
is_05 >> c;
VERIFY( c == 'a' );
is_05 >> f;
! VERIFY( f == 5.0 );
VERIFY( is_05.rdstate() == std::ios_base::failbit );
is_05.clear();
is_05.ignore();
--- 110,125 ----
is_05 >> f;
VERIFY( f == 0 );
+ f = 1;
is_05 >> f;
! VERIFY( f == 0 );
! VERIFY( is_05.rdstate() == std::ios_base::failbit );
is_05.clear();
is_05 >> c;
VERIFY( c == 'a' );
+ f = 1;
is_05 >> f;
! VERIFY( f == 0 );
VERIFY( is_05.rdstate() == std::ios_base::failbit );
is_05.clear();
is_05.ignore();
Index: testsuite/22_locale/num_get/get/wchar_t/22131.cc
===================================================================
*** testsuite/22_locale/num_get/get/wchar_t/22131.cc (revision 140573)
--- testsuite/22_locale/num_get/get/wchar_t/22131.cc (working copy)
*************** void test01()
*** 64,70 ****
end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
VERIFY( err == ios_base::failbit );
VERIFY( *end == L'#' );
! VERIFY( l == l1 );
iss1.str(L"0#0#0#2");
iss1.clear();
--- 64,70 ----
end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
VERIFY( err == ios_base::failbit );
VERIFY( *end == L'#' );
! VERIFY( l == 0 );
iss1.str(L"0#0#0#2");
iss1.clear();
*************** void test01()
*** 86,92 ****
end = ng1.get(iss1.rdbuf(), 0, iss1, err, d);
VERIFY( err == ios_base::failbit );
VERIFY( *end == L'#' );
! VERIFY( d == d1 );
iss1.str(L"0#0#0#2");
iss1.clear();
--- 86,92 ----
end = ng1.get(iss1.rdbuf(), 0, iss1, err, d);
VERIFY( err == ios_base::failbit );
VERIFY( *end == L'#' );
! VERIFY( d == 0.0 );
iss1.str(L"0#0#0#2");
iss1.clear();
*************** void test01()
*** 102,108 ****
end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
VERIFY( err == ios_base::failbit );
VERIFY( *end == L'#' );
! VERIFY( l == l2 );
iss1.str(L"00#0#3");
iss1.clear();
--- 102,108 ----
end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
VERIFY( err == ios_base::failbit );
VERIFY( *end == L'#' );
! VERIFY( l == 0 );
iss1.str(L"00#0#3");
iss1.clear();
Index: testsuite/22_locale/num_get/get/wchar_t/10.cc
===================================================================
*** testsuite/22_locale/num_get/get/wchar_t/10.cc (revision 140573)
--- testsuite/22_locale/num_get/get/wchar_t/10.cc (working copy)
***************
*** 1,6 ****
// 2003-12-19 Paolo Carlini <pcarlini@suse.de>
! // Copyright (C) 2003 Free Software Foundation
//
// 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
--- 1,6 ----
// 2003-12-19 Paolo Carlini <pcarlini@suse.de>
! // Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation
//
// 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
*************** void test01()
*** 45,68 ****
iss.str(L"1e.");
err = ios_base::goodbit;
end = ng.get(iss.rdbuf(), 0, iss, err, f);
! VERIFY( err == ios_base::goodbit );
VERIFY( *end == L'.' );
! VERIFY( f == f1 );
iss.str(L"3e+");
iss.clear();
err = ios_base::goodbit;
end = ng.get(iss.rdbuf(), 0, iss, err, d);
! VERIFY( err == ios_base::eofbit );
! VERIFY( d == d1 );
iss.str(L"6e ");
iss.clear();
err = ios_base::goodbit;
end = ng.get(iss.rdbuf(), 0, iss, err, ld);
! VERIFY( err == ios_base::goodbit );
VERIFY( *end == L' ' );
! VERIFY( ld == ld1 );
}
int main()
--- 45,68 ----
iss.str(L"1e.");
err = ios_base::goodbit;
end = ng.get(iss.rdbuf(), 0, iss, err, f);
! VERIFY( err == ios_base::failbit );
VERIFY( *end == L'.' );
! VERIFY( f == 0.0f );
iss.str(L"3e+");
iss.clear();
err = ios_base::goodbit;
end = ng.get(iss.rdbuf(), 0, iss, err, d);
! VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
! VERIFY( d == 0.0 );
iss.str(L"6e ");
iss.clear();
err = ios_base::goodbit;
end = ng.get(iss.rdbuf(), 0, iss, err, ld);
! VERIFY( err == ios_base::failbit );
VERIFY( *end == L' ' );
! VERIFY( ld == 0.0l );
}
int main()
Index: testsuite/22_locale/num_get/get/wchar_t/12.cc
===================================================================
*** testsuite/22_locale/num_get/get/wchar_t/12.cc (revision 140573)
--- testsuite/22_locale/num_get/get/wchar_t/12.cc (working copy)
***************
*** 1,6 ****
// 2003-12-22 Paolo Carlini <pcarlini@suse.de>
! // Copyright (C) 2003, 2004, 2005 Free Software Foundation
//
// 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
--- 1,6 ----
// 2003-12-22 Paolo Carlini <pcarlini@suse.de>
! // Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation
//
// 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
*************** void test01()
*** 129,135 ****
end = ng2.get(iss2.rdbuf(), 0, iss2, err, l);
VERIFY( err == ios_base::failbit );
VERIFY( *end == L'X' );
! VERIFY( l == l3 );
iss2.str(L"000778");
iss2.clear();
--- 129,135 ----
end = ng2.get(iss2.rdbuf(), 0, iss2, err, l);
VERIFY( err == ios_base::failbit );
VERIFY( *end == L'X' );
! VERIFY( l == 0 );
iss2.str(L"000778");
iss2.clear();
Index: testsuite/22_locale/num_get/get/wchar_t/15.cc
===================================================================
*** testsuite/22_locale/num_get/get/wchar_t/15.cc (revision 140573)
--- testsuite/22_locale/num_get/get/wchar_t/15.cc (working copy)
***************
*** 1,6 ****
// 2004-03-01 Paolo Carlini <pcarlini@suse.de>
! // Copyright (C) 2004 Free Software Foundation
//
// 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
--- 1,6 ----
// 2004-03-01 Paolo Carlini <pcarlini@suse.de>
! // Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation
//
// 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
*************** void test01()
*** 51,71 ****
ios_base::iostate err = ios_base::goodbit;
iterator_type end;
! double d = 0.0;
! double d1 = 1.0;
! double d2 = 3.0;
iss1.str(L"1e+2");
err = ios_base::goodbit;
end = ng1.get(iss1.rdbuf(), 0, iss1, err, d);
! VERIFY( err == ios_base::goodbit );
! VERIFY( d == d1 );
iss2.str(L"3e-1");
err = ios_base::goodbit;
end = ng2.get(iss2.rdbuf(), 0, iss2, err, d);
! VERIFY( err == ios_base::goodbit );
! VERIFY( d == d2 );
}
int main()
--- 51,72 ----
ios_base::iostate err = ios_base::goodbit;
iterator_type end;
! double d = 1.0;
iss1.str(L"1e+2");
err = ios_base::goodbit;
end = ng1.get(iss1.rdbuf(), 0, iss1, err, d);
! VERIFY( err == ios_base::failbit );
! VERIFY( *end == L'+' );
! VERIFY( d == 0.0 );
iss2.str(L"3e-1");
err = ios_base::goodbit;
+ d = 1.0;
end = ng2.get(iss2.rdbuf(), 0, iss2, err, d);
! VERIFY( err == ios_base::failbit );
! VERIFY( *end == L'-' );
! VERIFY( d == 0.0 );
}
int main()
Index: testsuite/22_locale/num_get/get/wchar_t/16.cc
===================================================================
*** testsuite/22_locale/num_get/get/wchar_t/16.cc (revision 140573)
--- testsuite/22_locale/num_get/get/wchar_t/16.cc (working copy)
***************
*** 1,6 ****
// 2005-04-26 Paolo Carlini <pcarlini@suse.de>
! // Copyright (C) 2005 Free Software Foundation
//
// 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
--- 1,6 ----
// 2005-04-26 Paolo Carlini <pcarlini@suse.de>
! // Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation
//
// 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
*************** void test01()
*** 64,70 ****
err = ios_base::goodbit;
end = ng.get(ss.rdbuf(), 0, ss, err, us0);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
! VERIFY( us0 == 0 );
ui0 = 0U;
ss.clear();
--- 64,70 ----
err = ios_base::goodbit;
end = ng.get(ss.rdbuf(), 0, ss, err, us0);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
! VERIFY( us0 == numeric_limits<unsigned short>::max() );
ui0 = 0U;
ss.clear();
*************** void test01()
*** 82,88 ****
err = ios_base::goodbit;
end = ng.get(ss.rdbuf(), 0, ss, err, ui0);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
! VERIFY( ui0 == 0U );
ul0 = 0UL;
ss.clear();
--- 82,88 ----
err = ios_base::goodbit;
end = ng.get(ss.rdbuf(), 0, ss, err, ui0);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
! VERIFY( ui0 == numeric_limits<unsigned int>::max() );
ul0 = 0UL;
ss.clear();
*************** void test01()
*** 100,106 ****
err = ios_base::goodbit;
end = ng.get(ss.rdbuf(), 0, ss, err, ul0);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
! VERIFY( ul0 == 0UL );
l01 = 0L;
ss.clear();
--- 100,106 ----
err = ios_base::goodbit;
end = ng.get(ss.rdbuf(), 0, ss, err, ul0);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
! VERIFY( ul0 == numeric_limits<unsigned long>::max() );
l01 = 0L;
ss.clear();
*************** void test01()
*** 118,124 ****
err = ios_base::goodbit;
end = ng.get(ss.rdbuf(), 0, ss, err, l01);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
! VERIFY( l01 == 0L );
l02 = 0L;
ss.clear();
--- 118,124 ----
err = ios_base::goodbit;
end = ng.get(ss.rdbuf(), 0, ss, err, l01);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
! VERIFY( l01 == numeric_limits<long>::max() );
l02 = 0L;
ss.clear();
*************** void test01()
*** 136,142 ****
err = ios_base::goodbit;
end = ng.get(ss.rdbuf(), 0, ss, err, l02);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
! VERIFY( l02 == 0L );
#ifdef _GLIBCXX_USE_LONG_LONG
ull0 = 0ULL;
--- 136,142 ----
err = ios_base::goodbit;
end = ng.get(ss.rdbuf(), 0, ss, err, l02);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
! VERIFY( l02 == numeric_limits<long>::min() );
#ifdef _GLIBCXX_USE_LONG_LONG
ull0 = 0ULL;
*************** void test01()
*** 155,161 ****
err = ios_base::goodbit;
end = ng.get(ss.rdbuf(), 0, ss, err, ull0);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
! VERIFY( ull0 == 0ULL );
ll01 = 0LL;
ss.clear();
--- 155,161 ----
err = ios_base::goodbit;
end = ng.get(ss.rdbuf(), 0, ss, err, ull0);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
! VERIFY( ull0 == numeric_limits<unsigned long long>::max() );
ll01 = 0LL;
ss.clear();
*************** void test01()
*** 173,179 ****
err = ios_base::goodbit;
end = ng.get(ss.rdbuf(), 0, ss, err, ll01);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
! VERIFY( ll01 == 0LL );
ll02 = 0LL;
ss.clear();
--- 173,179 ----
err = ios_base::goodbit;
end = ng.get(ss.rdbuf(), 0, ss, err, ll01);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
! VERIFY( ll01 == numeric_limits<long long>::max() );
ll02 = 0LL;
ss.clear();
*************** void test01()
*** 191,197 ****
err = ios_base::goodbit;
end = ng.get(ss.rdbuf(), 0, ss, err, ll02);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
! VERIFY( ll02 == 0LL );
#endif
}
--- 191,197 ----
err = ios_base::goodbit;
end = ng.get(ss.rdbuf(), 0, ss, err, ll02);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
! VERIFY( ll02 == numeric_limits<long long>::min() );
#endif
}
Index: testsuite/22_locale/num_get/get/char/22131.cc
===================================================================
*** testsuite/22_locale/num_get/get/char/22131.cc (revision 140573)
--- testsuite/22_locale/num_get/get/char/22131.cc (working copy)
***************
*** 1,6 ****
// 2005-06-28 Paolo Carlini <pcarlini@suse.de>
! // Copyright (C) 2005 Free Software Foundation
//
// 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
--- 1,6 ----
// 2005-06-28 Paolo Carlini <pcarlini@suse.de>
! // Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation
//
// 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
*************** void test01()
*** 64,70 ****
end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
VERIFY( err == ios_base::failbit );
VERIFY( *end == '#' );
! VERIFY( l == l1 );
iss1.str("0#0#0#2");
iss1.clear();
--- 64,70 ----
end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
VERIFY( err == ios_base::failbit );
VERIFY( *end == '#' );
! VERIFY( l == 0 );
iss1.str("0#0#0#2");
iss1.clear();
*************** void test01()
*** 86,92 ****
end = ng1.get(iss1.rdbuf(), 0, iss1, err, d);
VERIFY( err == ios_base::failbit );
VERIFY( *end == '#' );
! VERIFY( d == d1 );
iss1.str("0#0#0#2");
iss1.clear();
--- 86,92 ----
end = ng1.get(iss1.rdbuf(), 0, iss1, err, d);
VERIFY( err == ios_base::failbit );
VERIFY( *end == '#' );
! VERIFY( d == 0.0 );
iss1.str("0#0#0#2");
iss1.clear();
*************** void test01()
*** 102,108 ****
end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
VERIFY( err == ios_base::failbit );
VERIFY( *end == '#' );
! VERIFY( l == l2 );
iss1.str("00#0#3");
iss1.clear();
--- 102,108 ----
end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
VERIFY( err == ios_base::failbit );
VERIFY( *end == '#' );
! VERIFY( l == 0 );
iss1.str("00#0#3");
iss1.clear();
Index: testsuite/22_locale/num_get/get/char/10.cc
===================================================================
*** testsuite/22_locale/num_get/get/char/10.cc (revision 140573)
--- testsuite/22_locale/num_get/get/char/10.cc (working copy)
***************
*** 1,6 ****
// 2003-12-19 Paolo Carlini <pcarlini@suse.de>
! // Copyright (C) 2003 Free Software Foundation
//
// 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
--- 1,6 ----
// 2003-12-19 Paolo Carlini <pcarlini@suse.de>
! // Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation
//
// 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
*************** void test01()
*** 45,68 ****
iss.str("1e.");
err = ios_base::goodbit;
end = ng.get(iss.rdbuf(), 0, iss, err, f);
! VERIFY( err == ios_base::goodbit );
VERIFY( *end == '.' );
! VERIFY( f == f1 );
iss.str("3e+");
iss.clear();
err = ios_base::goodbit;
end = ng.get(iss.rdbuf(), 0, iss, err, d);
! VERIFY( err == ios_base::eofbit );
! VERIFY( d == d1 );
iss.str("6e ");
iss.clear();
err = ios_base::goodbit;
end = ng.get(iss.rdbuf(), 0, iss, err, ld);
! VERIFY( err == ios_base::goodbit );
VERIFY( *end == ' ' );
! VERIFY( ld == ld1 );
}
int main()
--- 45,68 ----
iss.str("1e.");
err = ios_base::goodbit;
end = ng.get(iss.rdbuf(), 0, iss, err, f);
! VERIFY( err == ios_base::failbit );
VERIFY( *end == '.' );
! VERIFY( f == 0.0f );
iss.str("3e+");
iss.clear();
err = ios_base::goodbit;
end = ng.get(iss.rdbuf(), 0, iss, err, d);
! VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
! VERIFY( d == 0.0 );
iss.str("6e ");
iss.clear();
err = ios_base::goodbit;
end = ng.get(iss.rdbuf(), 0, iss, err, ld);
! VERIFY( err == ios_base::failbit );
VERIFY( *end == ' ' );
! VERIFY( ld == 0.0l );
}
int main()
Index: testsuite/22_locale/num_get/get/char/12.cc
===================================================================
*** testsuite/22_locale/num_get/get/char/12.cc (revision 140573)
--- testsuite/22_locale/num_get/get/char/12.cc (working copy)
***************
*** 1,6 ****
// 2003-12-22 Paolo Carlini <pcarlini@suse.de>
! // Copyright (C) 2003, 2004, 2005 Free Software Foundation
//
// 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
--- 1,6 ----
// 2003-12-22 Paolo Carlini <pcarlini@suse.de>
! // Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation
//
// 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
*************** void test01()
*** 129,135 ****
end = ng2.get(iss2.rdbuf(), 0, iss2, err, l);
VERIFY( err == ios_base::failbit );
VERIFY( *end == 'X' );
! VERIFY( l == l3 );
iss2.str("000778");
iss2.clear();
--- 129,135 ----
end = ng2.get(iss2.rdbuf(), 0, iss2, err, l);
VERIFY( err == ios_base::failbit );
VERIFY( *end == 'X' );
! VERIFY( l == 0 );
iss2.str("000778");
iss2.clear();
Index: testsuite/22_locale/num_get/get/char/15.cc
===================================================================
*** testsuite/22_locale/num_get/get/char/15.cc (revision 140573)
--- testsuite/22_locale/num_get/get/char/15.cc (working copy)
***************
*** 1,6 ****
// 2004-03-01 Paolo Carlini <pcarlini@suse.de>
! // Copyright (C) 2004 Free Software Foundation
//
// 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
--- 1,6 ----
// 2004-03-01 Paolo Carlini <pcarlini@suse.de>
! // Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation
//
// 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
*************** void test01()
*** 51,71 ****
ios_base::iostate err = ios_base::goodbit;
iterator_type end;
! double d = 0.0;
! double d1 = 1.0;
! double d2 = 3.0;
iss1.str("1e+2");
err = ios_base::goodbit;
end = ng1.get(iss1.rdbuf(), 0, iss1, err, d);
! VERIFY( err == ios_base::goodbit );
! VERIFY( d == d1 );
iss2.str("3e-1");
err = ios_base::goodbit;
end = ng2.get(iss2.rdbuf(), 0, iss2, err, d);
! VERIFY( err == ios_base::goodbit );
! VERIFY( d == d2 );
}
int main()
--- 51,72 ----
ios_base::iostate err = ios_base::goodbit;
iterator_type end;
! double d = 1.0;
iss1.str("1e+2");
err = ios_base::goodbit;
end = ng1.get(iss1.rdbuf(), 0, iss1, err, d);
! VERIFY( err == ios_base::failbit );
! VERIFY( *end == '+' );
! VERIFY( d == 0.0 );
iss2.str("3e-1");
err = ios_base::goodbit;
+ d = 1.0;
end = ng2.get(iss2.rdbuf(), 0, iss2, err, d);
! VERIFY( err == ios_base::failbit );
! VERIFY( *end == '-' );
! VERIFY( d == 0.0 );
}
int main()
Index: testsuite/22_locale/num_get/get/char/16.cc
===================================================================
*** testsuite/22_locale/num_get/get/char/16.cc (revision 140573)
--- testsuite/22_locale/num_get/get/char/16.cc (working copy)
***************
*** 1,6 ****
// 2005-04-26 Paolo Carlini <pcarlini@suse.de>
! // Copyright (C) 2005 Free Software Foundation
//
// 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
--- 1,6 ----
// 2005-04-26 Paolo Carlini <pcarlini@suse.de>
! // Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation
//
// 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
*************** void test01()
*** 64,70 ****
err = ios_base::goodbit;
end = ng.get(ss.rdbuf(), 0, ss, err, us0);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
! VERIFY( us0 == 0 );
ui0 = 0U;
ss.clear();
--- 64,70 ----
err = ios_base::goodbit;
end = ng.get(ss.rdbuf(), 0, ss, err, us0);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
! VERIFY( us0 == numeric_limits<unsigned short>::max() );
ui0 = 0U;
ss.clear();
*************** void test01()
*** 82,88 ****
err = ios_base::goodbit;
end = ng.get(ss.rdbuf(), 0, ss, err, ui0);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
! VERIFY( ui0 == 0U );
ul0 = 0UL;
ss.clear();
--- 82,88 ----
err = ios_base::goodbit;
end = ng.get(ss.rdbuf(), 0, ss, err, ui0);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
! VERIFY( ui0 == numeric_limits<unsigned int>::max() );
ul0 = 0UL;
ss.clear();
*************** void test01()
*** 100,106 ****
err = ios_base::goodbit;
end = ng.get(ss.rdbuf(), 0, ss, err, ul0);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
! VERIFY( ul0 == 0UL );
l01 = 0L;
ss.clear();
--- 100,106 ----
err = ios_base::goodbit;
end = ng.get(ss.rdbuf(), 0, ss, err, ul0);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
! VERIFY( ul0 == numeric_limits<unsigned long>::max() );
l01 = 0L;
ss.clear();
*************** void test01()
*** 118,124 ****
err = ios_base::goodbit;
end = ng.get(ss.rdbuf(), 0, ss, err, l01);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
! VERIFY( l01 == 0L );
l02 = 0L;
ss.clear();
--- 118,124 ----
err = ios_base::goodbit;
end = ng.get(ss.rdbuf(), 0, ss, err, l01);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
! VERIFY( l01 == numeric_limits<long>::max() );
l02 = 0L;
ss.clear();
*************** void test01()
*** 136,142 ****
err = ios_base::goodbit;
end = ng.get(ss.rdbuf(), 0, ss, err, l02);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
! VERIFY( l02 == 0L );
#ifdef _GLIBCXX_USE_LONG_LONG
ull0 = 0ULL;
--- 136,142 ----
err = ios_base::goodbit;
end = ng.get(ss.rdbuf(), 0, ss, err, l02);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
! VERIFY( l02 == numeric_limits<long>::min() );
#ifdef _GLIBCXX_USE_LONG_LONG
ull0 = 0ULL;
*************** void test01()
*** 155,161 ****
err = ios_base::goodbit;
end = ng.get(ss.rdbuf(), 0, ss, err, ull0);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
! VERIFY( ull0 == 0ULL );
ll01 = 0LL;
ss.clear();
--- 155,161 ----
err = ios_base::goodbit;
end = ng.get(ss.rdbuf(), 0, ss, err, ull0);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
! VERIFY( ull0 == numeric_limits<unsigned long long>::max() );
ll01 = 0LL;
ss.clear();
*************** void test01()
*** 173,179 ****
err = ios_base::goodbit;
end = ng.get(ss.rdbuf(), 0, ss, err, ll01);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
! VERIFY( ll01 == 0LL );
ll02 = 0LL;
ss.clear();
--- 173,179 ----
err = ios_base::goodbit;
end = ng.get(ss.rdbuf(), 0, ss, err, ll01);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
! VERIFY( ll01 == numeric_limits<long long>::max() );
ll02 = 0LL;
ss.clear();
*************** void test01()
*** 191,197 ****
err = ios_base::goodbit;
end = ng.get(ss.rdbuf(), 0, ss, err, ll02);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
! VERIFY( ll02 == 0LL );
#endif
}
--- 191,197 ----
err = ios_base::goodbit;
end = ng.get(ss.rdbuf(), 0, ss, err, ll02);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
! VERIFY( ll02 == numeric_limits<long long>::min() );
#endif
}
Index: config/locale/gnu/c_locale.cc
===================================================================
*** config/locale/gnu/c_locale.cc (revision 140573)
--- config/locale/gnu/c_locale.cc (working copy)
***************
*** 1,6 ****
// Wrapper for underlying C-language localization -*- C++ -*-
! // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
--- 1,6 ----
// Wrapper for underlying C-language localization -*- C++ -*-
! // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
***************
*** 36,41 ****
--- 36,42 ----
#include <locale>
#include <stdexcept>
+ #include <limits>
#include <langinfo.h>
#include <bits/c++locale_internal.h>
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 47,58 ****
const __c_locale& __cloc)
{
char* __sanity;
! float __f = __strtof_l(__s, &__sanity, __cloc);
! if (__sanity != __s && __f != __builtin_huge_valf()
! && __f != -__builtin_huge_valf())
! __v = __f;
! else
! __err |= ios_base::failbit;
}
template<>
--- 48,72 ----
const __c_locale& __cloc)
{
char* __sanity;
! __v = __strtof_l(__s, &__sanity, __cloc);
!
! // _GLIBCXX_RESOLVE_LIB_DEFECTS
! // 23. Num_get overflow result.
! if (__sanity == __s || *__sanity != '\0')
! {
! __v = 0.0f;
! __err = ios_base::failbit;
! }
! else if (__v == numeric_limits<float>::infinity())
! {
! __v = numeric_limits<float>::max();
! __err = ios_base::failbit;
! }
! else if (__v == -numeric_limits<float>::infinity())
! {
! __v = -numeric_limits<float>::max();
! __err = ios_base::failbit;
! }
}
template<>
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 61,72 ****
const __c_locale& __cloc)
{
char* __sanity;
! double __d = __strtod_l(__s, &__sanity, __cloc);
! if (__sanity != __s && __d != __builtin_huge_val()
! && __d != -__builtin_huge_val())
! __v = __d;
! else
! __err |= ios_base::failbit;
}
template<>
--- 75,99 ----
const __c_locale& __cloc)
{
char* __sanity;
! __v = __strtod_l(__s, &__sanity, __cloc);
!
! // _GLIBCXX_RESOLVE_LIB_DEFECTS
! // 23. Num_get overflow result.
! if (__sanity == __s || *__sanity != '\0')
! {
! __v = 0.0;
! __err = ios_base::failbit;
! }
! else if (__v == numeric_limits<double>::infinity())
! {
! __v = numeric_limits<double>::max();
! __err = ios_base::failbit;
! }
! else if (__v == -numeric_limits<double>::infinity())
! {
! __v = -numeric_limits<double>::max();
! __err = ios_base::failbit;
! }
}
template<>
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 78,92 ****
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
// Prefer strtold_l, as __strtold_l isn't prototyped in more recent
// glibc versions.
! long double __ld = strtold_l(__s, &__sanity, __cloc);
#else
! long double __ld = __strtold_l(__s, &__sanity, __cloc);
#endif
! if (__sanity != __s && __ld != __builtin_huge_vall()
! && __ld != -__builtin_huge_vall())
! __v = __ld;
! else
! __err |= ios_base::failbit;
}
void
--- 105,132 ----
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
// Prefer strtold_l, as __strtold_l isn't prototyped in more recent
// glibc versions.
! __v = strtold_l(__s, &__sanity, __cloc);
#else
! __v = __strtold_l(__s, &__sanity, __cloc);
#endif
!
! // _GLIBCXX_RESOLVE_LIB_DEFECTS
! // 23. Num_get overflow result.
! if (__sanity == __s || *__sanity != '\0')
! {
! __v = 0.0l;
! __err = ios_base::failbit;
! }
! else if (__v == numeric_limits<long double>::infinity())
! {
! __v = numeric_limits<long double>::max();
! __err = ios_base::failbit;
! }
! else if (__v == -numeric_limits<long double>::infinity())
! {
! __v = -numeric_limits<long double>::max();
! __err = ios_base::failbit;
! }
}
void
Index: config/locale/generic/c_locale.cc
===================================================================
*** config/locale/generic/c_locale.cc (revision 140573)
--- config/locale/generic/c_locale.cc (working copy)
***************
*** 49,55 ****
_GLIBCXX_BEGIN_NAMESPACE(std)
- // Specializations for all types used in num_get.
template<>
void
__convert_to_v(const char* __s, float& __v, ios_base::iostate& __err,
--- 49,54 ----
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 62,101 ****
memcpy(__sav, __old, __len);
setlocale(LC_ALL, "C");
char* __sanity;
#if !__FLT_HAS_INFINITY__
errno = 0;
#endif
! #if defined(_GLIBCXX_HAVE_STRTOF)
! float __f = strtof(__s, &__sanity);
#else
double __d = strtod(__s, &__sanity);
! float __f = static_cast<float>(__d);
#ifdef _GLIBCXX_HAVE_FINITEF
! if (!finitef (__f))
! __s = __sanity;
#elif defined (_GLIBCXX_HAVE_FINITE)
! if (!finite (static_cast<double> (__f)))
! __s = __sanity;
#elif defined (_GLIBCXX_HAVE_ISINF)
! if (isinf (static_cast<double> (__f)))
! __s = __sanity;
#else
if (fabs(__d) > numeric_limits<float>::max())
! __s = __sanity;
! #endif
#endif
! if (__sanity != __s
! #if !__FLT_HAS_INFINITY__
! && errno != ERANGE)
! #else
! && __f != __builtin_huge_valf() && __f != -__builtin_huge_valf())
! #endif
! __v = __f;
! else
! __err |= ios_base::failbit;
setlocale(LC_ALL, __sav);
delete [] __sav;
--- 61,113 ----
memcpy(__sav, __old, __len);
setlocale(LC_ALL, "C");
char* __sanity;
+ bool __overflow = false;
#if !__FLT_HAS_INFINITY__
errno = 0;
#endif
! #ifdef _GLIBCXX_HAVE_STRTOF
! __v = strtof(__s, &__sanity);
#else
double __d = strtod(__s, &__sanity);
! __v = static_cast<float>(__d);
#ifdef _GLIBCXX_HAVE_FINITEF
! if (!finitef (__v))
! __overflow = true;
#elif defined (_GLIBCXX_HAVE_FINITE)
! if (!finite (static_cast<double> (__v)))
! __overflow = true;
#elif defined (_GLIBCXX_HAVE_ISINF)
! if (isinf (static_cast<double> (__v)))
! __overflow = true;
#else
if (fabs(__d) > numeric_limits<float>::max())
! __overflow = true;
#endif
+ #endif // _GLIBCXX_HAVE_STRTOF
! // _GLIBCXX_RESOLVE_LIB_DEFECTS
! // 23. Num_get overflow result.
! if (__sanity == __s || *__sanity != '\0')
! {
! __v = 0.0f;
! __err = ios_base::failbit;
! }
! else if (__overflow
! #if __FLT_HAS_INFINITY__
! || __v == numeric_limits<float>::infinity()
! || __v == -numeric_limits<float>::infinity())
! #else
! || ((__v > 1.0f || __v < -1.0f) && errno == ERANGE)
! #endif
! {
! if (__v > 0.0f)
! __v = numeric_limits<float>::max();
! else
! __v = -numeric_limits<float>::max();
! __err = ios_base::failbit;
! }
setlocale(LC_ALL, __sav);
delete [] __sav;
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 118,134 ****
errno = 0;
#endif
! double __d = strtod(__s, &__sanity);
! if (__sanity != __s
! #if !__DBL_HAS_INFINITY__
! && errno != ERANGE)
! #else
! && __d != __builtin_huge_val() && __d != -__builtin_huge_val())
! #endif
! __v = __d;
! else
! __err |= ios_base::failbit;
setlocale(LC_ALL, __sav);
delete [] __sav;
--- 130,158 ----
errno = 0;
#endif
! __v = strtod(__s, &__sanity);
! // _GLIBCXX_RESOLVE_LIB_DEFECTS
! // 23. Num_get overflow result.
! if (__sanity == __s || *__sanity != '\0')
! {
! __v = 0.0;
! __err = ios_base::failbit;
! }
! else if (
! #if __DBL_HAS_INFINITY__
! __v == numeric_limits<double>::infinity()
! || __v == -numeric_limits<double>::infinity())
! #else
! (__v > 1.0 || __v < -1.0) && errno == ERANGE)
! #endif
! {
! if (__v > 0.0)
! __v = numeric_limits<double>::max();
! else
! __v = -numeric_limits<double>::max();
! __err = ios_base::failbit;
! }
setlocale(LC_ALL, __sav);
delete [] __sav;
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 152,183 ****
#if defined(_GLIBCXX_HAVE_STRTOLD) && !defined(_GLIBCXX_HAVE_BROKEN_STRTOLD)
char* __sanity;
! long double __ld = strtold(__s, &__sanity);
!
! if (__sanity != __s
! #if !__LDBL_HAS_INFINITY__
! && errno != ERANGE)
! #else
! && __ld != __builtin_huge_vall() && __ld != -__builtin_huge_vall())
! #endif
! __v = __ld;
#else
typedef char_traits<char>::int_type int_type;
! long double __ld;
! int __p = sscanf(__s, "%Lf", &__ld);
!
! if (__p && static_cast<int_type>(__p) != char_traits<char>::eof()
! #if !__LDBL_HAS_INFINITY__
! && errno != ERANGE)
! #else
! && __ld != __builtin_huge_vall() && __ld != -__builtin_huge_vall())
! #endif
! __v = __ld;
#endif
! else
! __err |= ios_base::failbit;
setlocale(LC_ALL, __sav);
delete [] __sav;
--- 176,210 ----
#if defined(_GLIBCXX_HAVE_STRTOLD) && !defined(_GLIBCXX_HAVE_BROKEN_STRTOLD)
char* __sanity;
! __v = strtold(__s, &__sanity);
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 23. Num_get overflow result.
+ if (__sanity == __s || *__sanity != '\0')
#else
typedef char_traits<char>::int_type int_type;
! int __p = sscanf(__s, "%Lf", &__v);
+ if (!__p || static_cast<int_type>(__p) == char_traits<char>::eof())
#endif
! {
! __v = 0.0l;
! __err = ios_base::failbit;
! }
! else if (
! #if __LDBL_HAS_INFINITY__
! __v == numeric_limits<long double>::infinity()
! || __v == -numeric_limits<long double>::infinity())
! #else
! (__v > 1.0l || __v < -1.0l) && errno == ERANGE)
! #endif
! {
! if (__v > 0.0l)
! __v = numeric_limits<long double>::max();
! else
! __v = -numeric_limits<long double>::max();
! __err = ios_base::failbit;
! }
setlocale(LC_ALL, __sav);
delete [] __sav;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [v3] Fix libstdc++/32422 (+ DR 23)
2008-09-23 8:13 [v3] Fix libstdc++/32422 (+ DR 23) Paolo Carlini
@ 2008-10-01 23:02 ` Andrew Pinski
2008-10-02 9:38 ` Paolo Carlini
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Pinski @ 2008-10-01 23:02 UTC (permalink / raw)
To: Paolo Carlini; +Cc: Gcc Patch List, libstdc++
[-- Attachment #1: Type: text/plain, Size: 546 bytes --]
On Mon, Sep 22, 2008 at 5:50 PM, Paolo Carlini <paolo.carlini@oracle.com> wrote:
> Hi,
>
> tested x86_64-linux multilib, gnu/generic locale models, committed to
> mainline.
This broke spu-elf because __FLT_HAS_INFINITY__ is not defined there
(float does not have infinities) and there was a missing closing ) for
that case.
Attached is the patch which I am going to apply as obvious after a
build for spu-elf has finished.
Thanks,
Andrew Pinski
ChangeLog:
* config/locale/generic/c_locale.cc (__convert_to_v): Fix
!__FLT_HAS_INFINITY__ case.
[-- Attachment #2: fixspulibstdc++.diff.txt --]
[-- Type: text/plain, Size: 686 bytes --]
Index: gcc/libstdc++-v3/config/locale/generic/c_locale.cc
===================================================================
--- gcc/libstdc++-v3/config/locale/generic/c_locale.cc (revision 140822)
+++ gcc/libstdc++-v3/config/locale/generic/c_locale.cc (working copy)
@@ -97,10 +97,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
else if (__overflow
#if __FLT_HAS_INFINITY__
|| __v == numeric_limits<float>::infinity()
- || __v == -numeric_limits<float>::infinity())
+ || __v == -numeric_limits<float>::infinity()
#else
|| ((__v > 1.0f || __v < -1.0f) && errno == ERANGE)
#endif
+ )
{
if (__v > 0.0f)
__v = numeric_limits<float>::max();
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [v3] Fix libstdc++/32422 (+ DR 23)
2008-10-01 23:02 ` Andrew Pinski
@ 2008-10-02 9:38 ` Paolo Carlini
0 siblings, 0 replies; 3+ messages in thread
From: Paolo Carlini @ 2008-10-02 9:38 UTC (permalink / raw)
To: Andrew Pinski; +Cc: Gcc Patch List, libstdc++
Andrew Pinski wrote:
> This broke spu-elf because __FLT_HAS_INFINITY__ is not defined there
> (float does not have infinities) and there was a missing closing ) for
> that case.
>
Oops, shame on me. Thanks Andrew.
Paolo.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-10-02 9:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-23 8:13 [v3] Fix libstdc++/32422 (+ DR 23) Paolo Carlini
2008-10-01 23:02 ` Andrew Pinski
2008-10-02 9:38 ` Paolo Carlini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).