diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2008-09-23 00:47:02 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2008-09-23 00:47:02 +0000 |
commit | 5ef46f95596c600cf4d17bf98f4804e6bd53cfc5 (patch) | |
tree | 9d02f6e05a6a1e62f93b452749b09a474b553c86 | |
parent | 441154b19b1e998fe06a8f9045df8b69fa5ca274 (diff) | |
download | gcc-5ef46f95596c600cf4d17bf98f4804e6bd53cfc5.zip gcc-5ef46f95596c600cf4d17bf98f4804e6bd53cfc5.tar.gz gcc-5ef46f95596c600cf4d17bf98f4804e6bd53cfc5.tar.bz2 |
PR libstdc++/32422, DR 23 [Ready in R60]
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.
From-SVN: r140574
17 files changed, 308 insertions, 154 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 6233eec..9af7547 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,47 @@ +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. + 2008-09-22 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/37391 diff --git a/libstdc++-v3/config/locale/generic/c_locale.cc b/libstdc++-v3/config/locale/generic/c_locale.cc index 47c2b4e..67efd9e 100644 --- a/libstdc++-v3/config/locale/generic/c_locale.cc +++ b/libstdc++-v3/config/locale/generic/c_locale.cc @@ -49,7 +49,6 @@ _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, @@ -62,40 +61,53 @@ _GLIBCXX_BEGIN_NAMESPACE(std) memcpy(__sav, __old, __len); setlocale(LC_ALL, "C"); char* __sanity; + bool __overflow = false; #if !__FLT_HAS_INFINITY__ errno = 0; #endif -#if defined(_GLIBCXX_HAVE_STRTOF) - float __f = strtof(__s, &__sanity); +#ifdef _GLIBCXX_HAVE_STRTOF + __v = strtof(__s, &__sanity); #else double __d = strtod(__s, &__sanity); - float __f = static_cast<float>(__d); + __v = static_cast<float>(__d); #ifdef _GLIBCXX_HAVE_FINITEF - if (!finitef (__f)) - __s = __sanity; + if (!finitef (__v)) + __overflow = true; #elif defined (_GLIBCXX_HAVE_FINITE) - if (!finite (static_cast<double> (__f))) - __s = __sanity; + if (!finite (static_cast<double> (__v))) + __overflow = true; #elif defined (_GLIBCXX_HAVE_ISINF) - if (isinf (static_cast<double> (__f))) - __s = __sanity; + if (isinf (static_cast<double> (__v))) + __overflow = true; #else if (fabs(__d) > numeric_limits<float>::max()) - __s = __sanity; + __overflow = true; #endif -#endif - - if (__sanity != __s -#if !__FLT_HAS_INFINITY__ - && errno != ERANGE) +#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 - && __f != __builtin_huge_valf() && __f != -__builtin_huge_valf()) + || ((__v > 1.0f || __v < -1.0f) && errno == ERANGE) #endif - __v = __f; - else - __err |= ios_base::failbit; + { + 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; @@ -118,17 +130,29 @@ _GLIBCXX_BEGIN_NAMESPACE(std) 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()) + __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 - __v = __d; - else - __err |= ios_base::failbit; + { + 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; @@ -152,32 +176,35 @@ _GLIBCXX_BEGIN_NAMESPACE(std) #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; + __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; - long double __ld; - int __p = sscanf(__s, "%Lf", &__ld); + int __p = sscanf(__s, "%Lf", &__v); - 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()) + if (!__p || static_cast<int_type>(__p) == char_traits<char>::eof()) #endif - __v = __ld; - + { + __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 - else - __err |= ios_base::failbit; + { + 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; diff --git a/libstdc++-v3/config/locale/gnu/c_locale.cc b/libstdc++-v3/config/locale/gnu/c_locale.cc index a811cc7..0e39d94 100644 --- a/libstdc++-v3/config/locale/gnu/c_locale.cc +++ b/libstdc++-v3/config/locale/gnu/c_locale.cc @@ -1,6 +1,6 @@ // Wrapper for underlying C-language localization -*- C++ -*- -// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 +// 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,6 +36,7 @@ #include <locale> #include <stdexcept> +#include <limits> #include <langinfo.h> #include <bits/c++locale_internal.h> @@ -47,12 +48,25 @@ _GLIBCXX_BEGIN_NAMESPACE(std) 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; + __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<> @@ -61,12 +75,25 @@ _GLIBCXX_BEGIN_NAMESPACE(std) 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; + __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<> @@ -78,15 +105,28 @@ _GLIBCXX_BEGIN_NAMESPACE(std) #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); + __v = strtold_l(__s, &__sanity, __cloc); #else - long double __ld = __strtold_l(__s, &__sanity, __cloc); + __v = __strtold_l(__s, &__sanity, __cloc); #endif - if (__sanity != __s && __ld != __builtin_huge_vall() - && __ld != -__builtin_huge_vall()) - __v = __ld; - else - __err |= ios_base::failbit; + + // _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 diff --git a/libstdc++-v3/doc/xml/manual/intro.xml b/libstdc++-v3/doc/xml/manual/intro.xml index b64b969..08e107a 100644 --- a/libstdc++-v3/doc/xml/manual/intro.xml +++ b/libstdc++-v3/doc/xml/manual/intro.xml @@ -192,6 +192,12 @@ <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> diff --git a/libstdc++-v3/include/bits/locale_facets.tcc b/libstdc++-v3/include/bits/locale_facets.tcc index 4961025..271f2bd 100644 --- a/libstdc++-v3/include/bits/locale_facets.tcc +++ b/libstdc++-v3/include/bits/locale_facets.tcc @@ -345,12 +345,9 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE if (!std::__verify_grouping(__lc->_M_grouping, __lc->_M_grouping_size, __found_grouping)) - __err |= ios_base::failbit; + __err = ios_base::failbit; } - // Finish up. - if (__testeof) - __err |= ios_base::eofbit; return __beg; } @@ -454,6 +451,7 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE 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; @@ -471,11 +469,11 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE break; if (__result > __smax) - __testfail = true; + __testoverflow = true; else { __result *= __base; - __testfail |= __result > __max - __digit; + __testoverflow |= __result > __max - __digit; __result += __digit; ++__sep_pos; } @@ -518,11 +516,11 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE if (__digit > 15) __digit -= 6; if (__result > __smax) - __testfail = true; + __testoverflow = true; else { __result *= __base; - __testfail |= __result > __max - __digit; + __testoverflow |= __result > __max - __digit; __result += __digit; ++__sep_pos; } @@ -544,14 +542,27 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE if (!std::__verify_grouping(__lc->_M_grouping, __lc->_M_grouping_size, __found_grouping)) - __err |= ios_base::failbit; + __err = ios_base::failbit; } - if (!__testfail && (__sep_pos || __found_zero - || __found_grouping.size())) - __v = __negative ? -__result : __result; + // _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 - __err |= ios_base::failbit; + __v = __negative ? -__result : __result; if (__testeof) __err |= ios_base::eofbit; @@ -576,7 +587,14 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE if (__l == 0 || __l == 1) __v = bool(__l); else - __err |= ios_base::failbit; + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 23. Num_get overflow result. + __v = true; + __err = ios_base::failbit; + if (__beg == __end) + __err |= ios_base::eofbit; + } } else { @@ -621,7 +639,12 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE else if (__testt && __n == __lc->_M_truename_size) __v = true; else - __err |= ios_base::failbit; + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 23. Num_get overflow result. + __v = false; + __err = ios_base::failbit; + } if (__testeof) __err |= ios_base::eofbit; @@ -683,6 +706,8 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE __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; } @@ -696,6 +721,8 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE __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; } @@ -710,6 +737,8 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE __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 @@ -724,6 +753,8 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE __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; } @@ -748,8 +779,7 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE // Reset from hex formatted input. __io.flags(__fmt); - if (!(__err & ios_base::failbit)) - __v = reinterpret_cast<void*>(__ul); + __v = reinterpret_cast<void*>(__ul); return __beg; } diff --git a/libstdc++-v3/testsuite/22_locale/num_get/get/char/10.cc b/libstdc++-v3/testsuite/22_locale/num_get/get/char/10.cc index 4252ee1..03e4a8e 100644 --- a/libstdc++-v3/testsuite/22_locale/num_get/get/char/10.cc +++ b/libstdc++-v3/testsuite/22_locale/num_get/get/char/10.cc @@ -1,6 +1,6 @@ // 2003-12-19 Paolo Carlini <pcarlini@suse.de> -// Copyright (C) 2003 Free Software Foundation +// 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 @@ -45,24 +45,24 @@ void test01() iss.str("1e."); err = ios_base::goodbit; end = ng.get(iss.rdbuf(), 0, iss, err, f); - VERIFY( err == ios_base::goodbit ); + VERIFY( err == ios_base::failbit ); VERIFY( *end == '.' ); - VERIFY( f == f1 ); + 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::eofbit ); - VERIFY( d == d1 ); + 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::goodbit ); + VERIFY( err == ios_base::failbit ); VERIFY( *end == ' ' ); - VERIFY( ld == ld1 ); + VERIFY( ld == 0.0l ); } int main() diff --git a/libstdc++-v3/testsuite/22_locale/num_get/get/char/12.cc b/libstdc++-v3/testsuite/22_locale/num_get/get/char/12.cc index 9d01ad7..c315a59 100644 --- a/libstdc++-v3/testsuite/22_locale/num_get/get/char/12.cc +++ b/libstdc++-v3/testsuite/22_locale/num_get/get/char/12.cc @@ -1,6 +1,6 @@ // 2003-12-22 Paolo Carlini <pcarlini@suse.de> -// Copyright (C) 2003, 2004, 2005 Free Software Foundation +// 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 @@ -129,7 +129,7 @@ void test01() end = ng2.get(iss2.rdbuf(), 0, iss2, err, l); VERIFY( err == ios_base::failbit ); VERIFY( *end == 'X' ); - VERIFY( l == l3 ); + VERIFY( l == 0 ); iss2.str("000778"); iss2.clear(); diff --git a/libstdc++-v3/testsuite/22_locale/num_get/get/char/15.cc b/libstdc++-v3/testsuite/22_locale/num_get/get/char/15.cc index 2af3672..f5c5ec4 100644 --- a/libstdc++-v3/testsuite/22_locale/num_get/get/char/15.cc +++ b/libstdc++-v3/testsuite/22_locale/num_get/get/char/15.cc @@ -1,6 +1,6 @@ // 2004-03-01 Paolo Carlini <pcarlini@suse.de> -// Copyright (C) 2004 Free Software Foundation +// 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 @@ -51,21 +51,22 @@ void test01() ios_base::iostate err = ios_base::goodbit; iterator_type end; - double d = 0.0; - double d1 = 1.0; - double d2 = 3.0; + 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::goodbit ); - VERIFY( d == d1 ); + 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::goodbit ); - VERIFY( d == d2 ); + VERIFY( err == ios_base::failbit ); + VERIFY( *end == '-' ); + VERIFY( d == 0.0 ); } int main() diff --git a/libstdc++-v3/testsuite/22_locale/num_get/get/char/16.cc b/libstdc++-v3/testsuite/22_locale/num_get/get/char/16.cc index c71e588..cdabe1e 100644 --- a/libstdc++-v3/testsuite/22_locale/num_get/get/char/16.cc +++ b/libstdc++-v3/testsuite/22_locale/num_get/get/char/16.cc @@ -1,6 +1,6 @@ // 2005-04-26 Paolo Carlini <pcarlini@suse.de> -// Copyright (C) 2005 Free Software Foundation +// 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 @@ -64,7 +64,7 @@ void test01() err = ios_base::goodbit; end = ng.get(ss.rdbuf(), 0, ss, err, us0); VERIFY( err == (ios_base::failbit | ios_base::eofbit) ); - VERIFY( us0 == 0 ); + VERIFY( us0 == numeric_limits<unsigned short>::max() ); ui0 = 0U; ss.clear(); @@ -82,7 +82,7 @@ void test01() err = ios_base::goodbit; end = ng.get(ss.rdbuf(), 0, ss, err, ui0); VERIFY( err == (ios_base::failbit | ios_base::eofbit) ); - VERIFY( ui0 == 0U ); + VERIFY( ui0 == numeric_limits<unsigned int>::max() ); ul0 = 0UL; ss.clear(); @@ -100,7 +100,7 @@ void test01() err = ios_base::goodbit; end = ng.get(ss.rdbuf(), 0, ss, err, ul0); VERIFY( err == (ios_base::failbit | ios_base::eofbit) ); - VERIFY( ul0 == 0UL ); + VERIFY( ul0 == numeric_limits<unsigned long>::max() ); l01 = 0L; ss.clear(); @@ -118,7 +118,7 @@ void test01() err = ios_base::goodbit; end = ng.get(ss.rdbuf(), 0, ss, err, l01); VERIFY( err == (ios_base::failbit | ios_base::eofbit) ); - VERIFY( l01 == 0L ); + VERIFY( l01 == numeric_limits<long>::max() ); l02 = 0L; ss.clear(); @@ -136,7 +136,7 @@ void test01() err = ios_base::goodbit; end = ng.get(ss.rdbuf(), 0, ss, err, l02); VERIFY( err == (ios_base::failbit | ios_base::eofbit) ); - VERIFY( l02 == 0L ); + VERIFY( l02 == numeric_limits<long>::min() ); #ifdef _GLIBCXX_USE_LONG_LONG ull0 = 0ULL; @@ -155,7 +155,7 @@ void test01() err = ios_base::goodbit; end = ng.get(ss.rdbuf(), 0, ss, err, ull0); VERIFY( err == (ios_base::failbit | ios_base::eofbit) ); - VERIFY( ull0 == 0ULL ); + VERIFY( ull0 == numeric_limits<unsigned long long>::max() ); ll01 = 0LL; ss.clear(); @@ -173,7 +173,7 @@ void test01() err = ios_base::goodbit; end = ng.get(ss.rdbuf(), 0, ss, err, ll01); VERIFY( err == (ios_base::failbit | ios_base::eofbit) ); - VERIFY( ll01 == 0LL ); + VERIFY( ll01 == numeric_limits<long long>::max() ); ll02 = 0LL; ss.clear(); @@ -191,7 +191,7 @@ void test01() err = ios_base::goodbit; end = ng.get(ss.rdbuf(), 0, ss, err, ll02); VERIFY( err == (ios_base::failbit | ios_base::eofbit) ); - VERIFY( ll02 == 0LL ); + VERIFY( ll02 == numeric_limits<long long>::min() ); #endif } diff --git a/libstdc++-v3/testsuite/22_locale/num_get/get/char/22131.cc b/libstdc++-v3/testsuite/22_locale/num_get/get/char/22131.cc index 827fd6c..60fa184 100644 --- a/libstdc++-v3/testsuite/22_locale/num_get/get/char/22131.cc +++ b/libstdc++-v3/testsuite/22_locale/num_get/get/char/22131.cc @@ -1,6 +1,6 @@ // 2005-06-28 Paolo Carlini <pcarlini@suse.de> -// Copyright (C) 2005 Free Software Foundation +// 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 @@ -64,7 +64,7 @@ void test01() end = ng1.get(iss1.rdbuf(), 0, iss1, err, l); VERIFY( err == ios_base::failbit ); VERIFY( *end == '#' ); - VERIFY( l == l1 ); + VERIFY( l == 0 ); iss1.str("0#0#0#2"); iss1.clear(); @@ -86,7 +86,7 @@ void test01() end = ng1.get(iss1.rdbuf(), 0, iss1, err, d); VERIFY( err == ios_base::failbit ); VERIFY( *end == '#' ); - VERIFY( d == d1 ); + VERIFY( d == 0.0 ); iss1.str("0#0#0#2"); iss1.clear(); @@ -102,7 +102,7 @@ void test01() end = ng1.get(iss1.rdbuf(), 0, iss1, err, l); VERIFY( err == ios_base::failbit ); VERIFY( *end == '#' ); - VERIFY( l == l2 ); + VERIFY( l == 0 ); iss1.str("00#0#3"); iss1.clear(); diff --git a/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/10.cc b/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/10.cc index 3860e08..425eba5 100644 --- a/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/10.cc +++ b/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/10.cc @@ -1,6 +1,6 @@ // 2003-12-19 Paolo Carlini <pcarlini@suse.de> -// Copyright (C) 2003 Free Software Foundation +// 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 @@ -45,24 +45,24 @@ void test01() iss.str(L"1e."); err = ios_base::goodbit; end = ng.get(iss.rdbuf(), 0, iss, err, f); - VERIFY( err == ios_base::goodbit ); + VERIFY( err == ios_base::failbit ); VERIFY( *end == L'.' ); - VERIFY( f == f1 ); + 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::eofbit ); - VERIFY( d == d1 ); + 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::goodbit ); + VERIFY( err == ios_base::failbit ); VERIFY( *end == L' ' ); - VERIFY( ld == ld1 ); + VERIFY( ld == 0.0l ); } int main() diff --git a/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/12.cc b/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/12.cc index 5a59e85..097b5ee 100644 --- a/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/12.cc +++ b/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/12.cc @@ -1,6 +1,6 @@ // 2003-12-22 Paolo Carlini <pcarlini@suse.de> -// Copyright (C) 2003, 2004, 2005 Free Software Foundation +// 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 @@ -129,7 +129,7 @@ void test01() end = ng2.get(iss2.rdbuf(), 0, iss2, err, l); VERIFY( err == ios_base::failbit ); VERIFY( *end == L'X' ); - VERIFY( l == l3 ); + VERIFY( l == 0 ); iss2.str(L"000778"); iss2.clear(); diff --git a/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/15.cc b/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/15.cc index be46d01..6b8613d 100644 --- a/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/15.cc +++ b/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/15.cc @@ -1,6 +1,6 @@ // 2004-03-01 Paolo Carlini <pcarlini@suse.de> -// Copyright (C) 2004 Free Software Foundation +// 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 @@ -51,21 +51,22 @@ void test01() ios_base::iostate err = ios_base::goodbit; iterator_type end; - double d = 0.0; - double d1 = 1.0; - double d2 = 3.0; + 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::goodbit ); - VERIFY( d == d1 ); + 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::goodbit ); - VERIFY( d == d2 ); + VERIFY( err == ios_base::failbit ); + VERIFY( *end == L'-' ); + VERIFY( d == 0.0 ); } int main() diff --git a/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/16.cc b/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/16.cc index 7062084..7795004 100644 --- a/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/16.cc +++ b/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/16.cc @@ -1,6 +1,6 @@ // 2005-04-26 Paolo Carlini <pcarlini@suse.de> -// Copyright (C) 2005 Free Software Foundation +// 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 @@ -64,7 +64,7 @@ void test01() err = ios_base::goodbit; end = ng.get(ss.rdbuf(), 0, ss, err, us0); VERIFY( err == (ios_base::failbit | ios_base::eofbit) ); - VERIFY( us0 == 0 ); + VERIFY( us0 == numeric_limits<unsigned short>::max() ); ui0 = 0U; ss.clear(); @@ -82,7 +82,7 @@ void test01() err = ios_base::goodbit; end = ng.get(ss.rdbuf(), 0, ss, err, ui0); VERIFY( err == (ios_base::failbit | ios_base::eofbit) ); - VERIFY( ui0 == 0U ); + VERIFY( ui0 == numeric_limits<unsigned int>::max() ); ul0 = 0UL; ss.clear(); @@ -100,7 +100,7 @@ void test01() err = ios_base::goodbit; end = ng.get(ss.rdbuf(), 0, ss, err, ul0); VERIFY( err == (ios_base::failbit | ios_base::eofbit) ); - VERIFY( ul0 == 0UL ); + VERIFY( ul0 == numeric_limits<unsigned long>::max() ); l01 = 0L; ss.clear(); @@ -118,7 +118,7 @@ void test01() err = ios_base::goodbit; end = ng.get(ss.rdbuf(), 0, ss, err, l01); VERIFY( err == (ios_base::failbit | ios_base::eofbit) ); - VERIFY( l01 == 0L ); + VERIFY( l01 == numeric_limits<long>::max() ); l02 = 0L; ss.clear(); @@ -136,7 +136,7 @@ void test01() err = ios_base::goodbit; end = ng.get(ss.rdbuf(), 0, ss, err, l02); VERIFY( err == (ios_base::failbit | ios_base::eofbit) ); - VERIFY( l02 == 0L ); + VERIFY( l02 == numeric_limits<long>::min() ); #ifdef _GLIBCXX_USE_LONG_LONG ull0 = 0ULL; @@ -155,7 +155,7 @@ void test01() err = ios_base::goodbit; end = ng.get(ss.rdbuf(), 0, ss, err, ull0); VERIFY( err == (ios_base::failbit | ios_base::eofbit) ); - VERIFY( ull0 == 0ULL ); + VERIFY( ull0 == numeric_limits<unsigned long long>::max() ); ll01 = 0LL; ss.clear(); @@ -173,7 +173,7 @@ void test01() err = ios_base::goodbit; end = ng.get(ss.rdbuf(), 0, ss, err, ll01); VERIFY( err == (ios_base::failbit | ios_base::eofbit) ); - VERIFY( ll01 == 0LL ); + VERIFY( ll01 == numeric_limits<long long>::max() ); ll02 = 0LL; ss.clear(); @@ -191,7 +191,7 @@ void test01() err = ios_base::goodbit; end = ng.get(ss.rdbuf(), 0, ss, err, ll02); VERIFY( err == (ios_base::failbit | ios_base::eofbit) ); - VERIFY( ll02 == 0LL ); + VERIFY( ll02 == numeric_limits<long long>::min() ); #endif } diff --git a/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/22131.cc b/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/22131.cc index 8bd76d7..6c622be 100644 --- a/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/22131.cc +++ b/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/22131.cc @@ -64,7 +64,7 @@ void test01() end = ng1.get(iss1.rdbuf(), 0, iss1, err, l); VERIFY( err == ios_base::failbit ); VERIFY( *end == L'#' ); - VERIFY( l == l1 ); + VERIFY( l == 0 ); iss1.str(L"0#0#0#2"); iss1.clear(); @@ -86,7 +86,7 @@ void test01() end = ng1.get(iss1.rdbuf(), 0, iss1, err, d); VERIFY( err == ios_base::failbit ); VERIFY( *end == L'#' ); - VERIFY( d == d1 ); + VERIFY( d == 0.0 ); iss1.str(L"0#0#0#2"); iss1.clear(); @@ -102,7 +102,7 @@ void test01() end = ng1.get(iss1.rdbuf(), 0, iss1, err, l); VERIFY( err == ios_base::failbit ); VERIFY( *end == L'#' ); - VERIFY( l == l2 ); + VERIFY( l == 0 ); iss1.str(L"00#0#3"); iss1.clear(); diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/10.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/10.cc index 0fd9209..3437a56 100644 --- a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/10.cc +++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/10.cc @@ -1,6 +1,7 @@ // 1999-04-12 bkoz -// Copyright (C) 1999, 2000, 2002, 2003 Free Software Foundation, Inc. +// 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 @@ -109,14 +110,16 @@ bool test10() is_05 >> f; VERIFY( f == 0 ); + f = 1; is_05 >> f; - VERIFY( f == 5.0 ); - VERIFY( is_05.rdstate() == std::ios_base::goodbit ); + 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 == 5.0 ); + VERIFY( f == 0 ); VERIFY( is_05.rdstate() == std::ios_base::failbit ); is_05.clear(); is_05.ignore(); diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/10.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/10.cc index 5e163d3..c4cc590 100644 --- a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/10.cc +++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/10.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2004 Free Software Foundation, Inc. +// 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 @@ -107,14 +107,16 @@ bool test10() is_05 >> f; VERIFY( f == 0 ); + f = 1; is_05 >> f; - VERIFY( f == 5.0 ); - VERIFY( is_05.rdstate() == std::ios_base::goodbit ); + 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 == 5.0 ); + VERIFY( f == 0 ); VERIFY( is_05.rdstate() == std::ios_base::failbit ); is_05.clear(); is_05.ignore(); |