diff options
author | Benjamin Kosnik <bkoz@redhat.com> | 2002-03-28 03:15:08 +0000 |
---|---|---|
committer | Benjamin Kosnik <bkoz@gcc.gnu.org> | 2002-03-28 03:15:08 +0000 |
commit | a3ebd14d24d97379462543660912c2536c2aafc2 (patch) | |
tree | 81a6cb7b237b4b31664811f7c6186b4cadf361c9 | |
parent | 47d0866c79c04d8d86ce3d1eff9dda7899179c4b (diff) | |
download | gcc-a3ebd14d24d97379462543660912c2536c2aafc2.zip gcc-a3ebd14d24d97379462543660912c2536c2aafc2.tar.gz gcc-a3ebd14d24d97379462543660912c2536c2aafc2.tar.bz2 |
ostream.tcc (ostream::operator<<(_CharT)): Always allocate at least a byte.
2002-03-27 Benjamin Kosnik <bkoz@redhat.com>
* include/bits/ostream.tcc (ostream::operator<<(_CharT)): Always
allocate at least a byte.
* testsuite/18_support/numeric_limits.cc (test_extrema): Make
debugger-friendly.
* testsuite/27_io/streambuf.cc (test07): Fix.
(test06): Enable.
From-SVN: r51494
-rw-r--r-- | libstdc++-v3/ChangeLog | 10 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/ostream.tcc | 2 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/18_support/numeric_limits.cc | 46 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/27_io/streambuf.cc | 13 |
4 files changed, 44 insertions, 27 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index f7a7d8e..e262607 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,13 @@ +2002-03-27 Benjamin Kosnik <bkoz@redhat.com> + + * include/bits/ostream.tcc (ostream::operator<<(_CharT)): Always + allocate at least a byte. + + * testsuite/18_support/numeric_limits.cc (test_extrema): Make + debugger-friendly. + * testsuite/27_io/streambuf.cc (test07): Fix. + (test06): Enable. + 2002-03-27 Phil Edwards <pme@gcc.gnu.org> * docs/doxygen/Intro.3: Date tweak. diff --git a/libstdc++-v3/include/bits/ostream.tcc b/libstdc++-v3/include/bits/ostream.tcc index e8c2a4f..9a26088 100644 --- a/libstdc++-v3/include/bits/ostream.tcc +++ b/libstdc++-v3/include/bits/ostream.tcc @@ -481,7 +481,7 @@ namespace std try { streamsize __w = __out.width(); - _CharT* __pads = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __w)); + _CharT* __pads = static_cast<_CharT*>(__builtin_alloca((sizeof(_CharT) * __w) + 1)); __pads[0] = __c; streamsize __len = 1; if (__w > __len) diff --git a/libstdc++-v3/testsuite/18_support/numeric_limits.cc b/libstdc++-v3/testsuite/18_support/numeric_limits.cc index bf9d9e0..8efaa46 100644 --- a/libstdc++-v3/testsuite/18_support/numeric_limits.cc +++ b/libstdc++-v3/testsuite/18_support/numeric_limits.cc @@ -1,6 +1,6 @@ // 1999-08-23 bkoz -// Copyright (C) 1999, 2001 Free Software Foundation +// Copyright (C) 1999, 2001, 2002 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 @@ -56,33 +56,39 @@ template<typename T> void test_extrema() { bool test = true; - VERIFY( extrema<T>::min == std::numeric_limits<T>::min() ); - VERIFY( extrema<T>::max == std::numeric_limits<T>::max() ); + T limits_min = std::numeric_limits<T>::min(); + T limits_max = std::numeric_limits<T>::max(); + T extrema_min = extrema<T>::min; + T extrema_max = extrema<T>::max; + VERIFY( extrema_min == limits_min ); + VERIFY( extrema_max == limits_max ); } #ifdef __FreeBSD__ -// This specialization allows the extra precision unmentioned -// in system headers yet supported by long double on FreeBSD to -// not cause a gratuitous FAIL for the entire test. Using this -// technique to compare the residual against epsilon ensures that -// any major breakage will still be detected (although obviously not -// as tight as the exact equality check that would have been generated -// by default). This replacement test is allowable by the fact that -// C++ limits should match the system provided limits for C even if -// they were wrong verses the actual FP hardware. +// This specialization allows the extra precision unmentioned in +// system headers yet supported by long double on FreeBSD or Solaris +// to not cause a gratuitous FAIL for the entire test. Using this +// technique to compare the residual against epsilon ensures that any +// major breakage will still be detected (although obviously not as +// tight as the exact equality check that would have been generated by +// default). This replacement test is allowable by the fact that C++ +// limits should match the system provided limits for C even if they +// were wrong verses the actual FP hardware. template<> void test_extrema<long double>() { typedef long double T; bool test = true; - VERIFY( (extrema<T>::min - std::numeric_limits<T>::min()) - < std::numeric_limits<T>::epsilon() ); - VERIFY( (std::numeric_limits<T>::min() - extrema<T>::min) - < std::numeric_limits<T>::epsilon() ); - VERIFY( (extrema<T>::max / std::numeric_limits<T>::max()) - < (1 + std::numeric_limits<T>::epsilon()) ); - VERIFY( (std::numeric_limits<T>::max() / extrema<T>::max) - < (1 + std::numeric_limits<T>::epsilon()) ); + T limits_min = std::numeric_limits<T>::min(); + T limits_max = std::numeric_limits<T>::max(); + T extrema_min = extrema<T>::min; + T extrema_max = extrema<T>::max; + T epsilon = std::numeric_limits<T>::epsilon(); + + VERIFY( (extrema_min - limits_min) < epsilon ); + VERIFY( (limits_min - extrema_min) < epsilon ); + VERIFY( (extrema_max - limits_max) < (1 + epsilon) ); + VERIFY( (limits_max - extrema_max) < (1 + epsilon) ); } #endif diff --git a/libstdc++-v3/testsuite/27_io/streambuf.cc b/libstdc++-v3/testsuite/27_io/streambuf.cc index a560390..3f9a319 100644 --- a/libstdc++-v3/testsuite/27_io/streambuf.cc +++ b/libstdc++-v3/testsuite/27_io/streambuf.cc @@ -1,6 +1,6 @@ // 1999-10-11 bkoz -// Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. +// Copyright (C) 1999, 2000, 2001, 2002 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 @@ -329,15 +329,12 @@ void test05() } // test06 -// XXX this should work, doesn't due to compiler limitations. -#if 0 namespace gnu { class something_derived; } class gnu::something_derived : std::streambuf { }; -#endif // libstdc++/3599 class testbuf2 : public std::streambuf @@ -356,11 +353,15 @@ protected: void test07() { + bool test = true; testbuf2 ob; std::ostream out(&ob); - VERIFY(out << "gasp"); - VERIFY(out << std::endl); + out << "gasp"; + VERIFY(out.good()); + + out << std::endl; + VERIFY(out.good()); } int main() |