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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@140574
138bc75d-0d04-0410-961f-
82ee72b054a4
+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
_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,
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;
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;
#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;
// 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
#include <locale>
#include <stdexcept>
+#include <limits>
#include <langinfo.h>
#include <bits/c++locale_internal.h>
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<>
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<>
#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
<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>
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;
}
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;
break;
if (__result > __smax)
- __testfail = true;
+ __testoverflow = true;
else
{
__result *= __base;
- __testfail |= __result > __max - __digit;
+ __testoverflow |= __result > __max - __digit;
__result += __digit;
++__sep_pos;
}
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;
}
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;
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
{
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;
__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;
}
__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;
}
__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
__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;
}
// 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;
}
// 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
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()
// 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
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();
// 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
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()
// 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
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();
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();
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();
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();
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;
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();
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();
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
}
// 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
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();
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();
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();
// 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
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()
// 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
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();
// 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
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()
// 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
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();
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();
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();
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();
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;
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();
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();
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
}
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();
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();
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();
// 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
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();
-// 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
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();