mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-02-21 05:39:25 +08:00
PR libstdc++/28277 (partial: ostream bits 1)
2006-07-15 Paolo Carlini <pcarlini@suse.de> PR libstdc++/28277 (partial: ostream bits 1) * include/bits/ostream.tcc (operator<<(basic_ostream<_CharT>&, const char*)): Avoid __builtin_alloca with no limit in the widening. * testsuite/27_io/basic_ostream/inserters_character/wchar_t/ 28277-1.cc: New. From-SVN: r115485
This commit is contained in:
parent
b0d5d5de78
commit
6f0cb13801
@ -1,17 +1,26 @@
|
|||||||
|
2006-07-15 Paolo Carlini <pcarlini@suse.de>
|
||||||
|
|
||||||
|
PR libstdc++/28277 (partial: ostream bits 1)
|
||||||
|
* include/bits/ostream.tcc (operator<<(basic_ostream<_CharT>&,
|
||||||
|
const char*)): Avoid __builtin_alloca with no limit in the
|
||||||
|
widening.
|
||||||
|
* testsuite/27_io/basic_ostream/inserters_character/wchar_t/
|
||||||
|
28277-1.cc: New.
|
||||||
|
|
||||||
2006-07-14 Benjamin Kosnik <bkoz@redhat.com>
|
2006-07-14 Benjamin Kosnik <bkoz@redhat.com>
|
||||||
|
|
||||||
* acinclude.m4 (GLIBCXX_ENABLE_ATOMIC_BUILTINS): New.
|
* acinclude.m4 (GLIBCXX_ENABLE_ATOMIC_BUILTINS): New.
|
||||||
* configure.ac: Use it.
|
* configure.ac: Use it.
|
||||||
* configure: Regenerated.
|
* configure: Regenerated.
|
||||||
* config.h.in: Regenerated.
|
* config.h.in: Regenerated.
|
||||||
* configure.host: Simplify.
|
* configure.host: Simplify.
|
||||||
* include/bits/atomicity.h: Adjust macros.
|
* include/bits/atomicity.h: Adjust macros.
|
||||||
* config/cpu/generic/atomicity.h: Move...
|
* config/cpu/generic/atomicity.h: Move...
|
||||||
* config/cpu/generic/atomicity_mutex: New.
|
* config/cpu/generic/atomicity_mutex: New.
|
||||||
* config/cpu/generic/atomicity_mutex/atomicity.h: ...here.
|
* config/cpu/generic/atomicity_mutex/atomicity.h: ...here.
|
||||||
* config/cpu/generic/atomic_builtins: Rename...
|
* config/cpu/generic/atomic_builtins: Rename...
|
||||||
* config/cpu/generic/atomicity_builtins: ...to this.
|
* config/cpu/generic/atomicity_builtins: ...to this.
|
||||||
* config/cpu/generic/atomicity_builtins/atomicity.h: Moved.
|
* config/cpu/generic/atomicity_builtins/atomicity.h: Moved.
|
||||||
* config/cpu/mips/atomicity.h: Comment MIPS II requirement.
|
* config/cpu/mips/atomicity.h: Comment MIPS II requirement.
|
||||||
|
|
||||||
* scripts/testsuite_flags.in: Make --cxxflags reflect CXXFLAGS.
|
* scripts/testsuite_flags.in: Make --cxxflags reflect CXXFLAGS.
|
||||||
|
@ -421,15 +421,15 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||||||
typename __ostream_type::sentry __cerb(__out);
|
typename __ostream_type::sentry __cerb(__out);
|
||||||
if (__cerb && __s)
|
if (__cerb && __s)
|
||||||
{
|
{
|
||||||
size_t __clen = __traits_type::length(__s);
|
_CharT* __ws = 0;
|
||||||
_CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
|
|
||||||
* __clen));
|
|
||||||
for (size_t __i = 0; __i < __clen; ++__i)
|
|
||||||
__ws[__i] = __out.widen(__s[__i]);
|
|
||||||
_CharT* __str = __ws;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
const size_t __clen = __traits_type::length(__s);
|
||||||
|
__ws = new _CharT[__clen];
|
||||||
|
for (size_t __i = 0; __i < __clen; ++__i)
|
||||||
|
__ws[__i] = __out.widen(__s[__i]);
|
||||||
|
_CharT* __str = __ws;
|
||||||
|
|
||||||
const streamsize __w = __out.width();
|
const streamsize __w = __out.width();
|
||||||
streamsize __len = static_cast<streamsize>(__clen);
|
streamsize __len = static_cast<streamsize>(__clen);
|
||||||
if (__w > __len)
|
if (__w > __len)
|
||||||
@ -444,9 +444,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||||||
}
|
}
|
||||||
__out._M_write(__str, __len);
|
__out._M_write(__str, __len);
|
||||||
__out.width(0);
|
__out.width(0);
|
||||||
|
|
||||||
|
delete [] __ws;
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{ __out._M_setstate(ios_base::badbit); }
|
{
|
||||||
|
delete [] __ws;
|
||||||
|
__out._M_setstate(ios_base::badbit);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (!__s)
|
else if (!__s)
|
||||||
__out.setstate(ios_base::badbit);
|
__out.setstate(ios_base::badbit);
|
||||||
|
@ -0,0 +1,46 @@
|
|||||||
|
// 2006-07-15 Paolo Carlini <pcarlini@suse.de>
|
||||||
|
|
||||||
|
// Copyright (C) 2006 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
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 2, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License along
|
||||||
|
// with this library; see the file COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// 27.6.2.5.4 basic_ostream character inserters
|
||||||
|
|
||||||
|
#include <ostream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
// libstdc++/28277
|
||||||
|
void test01()
|
||||||
|
{
|
||||||
|
using namespace std;
|
||||||
|
bool test __attribute__((unused)) = true;
|
||||||
|
|
||||||
|
wostringstream oss_01;
|
||||||
|
const string str_01(5000000, 'a');
|
||||||
|
|
||||||
|
oss_01 << str_01.c_str();
|
||||||
|
|
||||||
|
VERIFY( oss_01.good() );
|
||||||
|
VERIFY( oss_01.str().size() == str_01.size() );
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test01();
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user