| 1 |
// PR debug/59510 |
| 2 |
// { dg-do compile } |
| 3 |
// { dg-options "-O2 -g --param=large-stack-frame-growth=1 -Wno-return-type" } |
| 4 |
|
| 5 |
template <typename _Iterator> |
| 6 |
struct _Iter_base |
| 7 |
{ |
| 8 |
typedef _Iterator iterator_type; |
| 9 |
}; |
| 10 |
template <typename _CharT> |
| 11 |
struct basic_ostream; |
| 12 |
template <typename _CharT> |
| 13 |
struct basic_ostringstream; |
| 14 |
template <typename _CharT> |
| 15 |
struct ostreambuf_iterator; |
| 16 |
typedef basic_ostringstream <char>ostringstream; |
| 17 |
template <typename _Iterator> struct _Miter_base : _Iter_base <_Iterator> |
| 18 |
{ |
| 19 |
}; |
| 20 |
template <typename _Iterator> |
| 21 |
typename _Miter_base <_Iterator>::iterator_type __miter_base (_Iterator); |
| 22 |
template <typename _CharT> |
| 23 |
ostreambuf_iterator <_CharT> |
| 24 |
__copy_move_a2 (ostreambuf_iterator <_CharT>); |
| 25 |
template <typename _II, typename _OI> |
| 26 |
_OI copy (_II __first, _II __last, _OI __result) |
| 27 |
{ |
| 28 |
__copy_move_a2 <false> (__first, __miter_base (__last), __result); |
| 29 |
} |
| 30 |
struct ios_base { |
| 31 |
struct _Words { |
| 32 |
int *_M_pword; |
| 33 |
long _M_iword; |
| 34 |
}; |
| 35 |
_Words _M_local_word[8]; |
| 36 |
}; |
| 37 |
template <typename _CharT> |
| 38 |
struct basic_streambuf |
| 39 |
{ |
| 40 |
typedef _CharT char_type; |
| 41 |
int sputn (char_type *, int); |
| 42 |
}; |
| 43 |
template <typename _CharT> |
| 44 |
struct ostreambuf_iterator |
| 45 |
{ |
| 46 |
typedef basic_streambuf <_CharT> streambuf_type; |
| 47 |
typedef basic_ostream <_CharT> ostream_type; |
| 48 |
streambuf_type *_M_sbuf; |
| 49 |
bool _M_failed; |
| 50 |
ostreambuf_iterator (ostream_type __s) : _M_sbuf (__s.rdbuf ()), _M_failed () {} |
| 51 |
void _M_put (_CharT * __ws, int __len) |
| 52 |
{ |
| 53 |
if (_M_failed && _M_sbuf->sputn (__ws, __len) != __len) _M_failed = true; |
| 54 |
} |
| 55 |
}; |
| 56 |
template <bool, typename _CharT> |
| 57 |
void __copy_move_a2 (_CharT * __first,_CharT * __last,ostreambuf_iterator <_CharT> __result) |
| 58 |
{ |
| 59 |
int __num = __last - __first; |
| 60 |
__result._M_put (__first, __num); |
| 61 |
} |
| 62 |
template <typename _CharT> |
| 63 |
struct basic_ios : ios_base |
| 64 |
{ |
| 65 |
basic_streambuf <_CharT> *rdbuf (); |
| 66 |
}; |
| 67 |
template <typename _CharT> |
| 68 |
struct basic_ostream : public basic_ios <_CharT> |
| 69 |
{ |
| 70 |
}; |
| 71 |
template <typename _CharT> |
| 72 |
struct basic_ostringstream : public basic_ostream <_CharT> |
| 73 |
{ |
| 74 |
}; |
| 75 |
void |
| 76 |
test01 () { |
| 77 |
char data1[] = "foo"; |
| 78 |
char *beg1 = data1; |
| 79 |
ostringstream oss1; |
| 80 |
ostreambuf_iterator <char> out1 (oss1); |
| 81 |
out1 = copy (beg1, beg1, out1); |
| 82 |
} |