]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/27_io/basic_istream/get/char/lwg3464.cc
1 // Copyright (C) 2020 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
18 // { dg-do run { target { ! lp64 } } }
23 #include <testsuite_hooks.h>
27 struct buff
: std::basic_streambuf
<C
>
29 typedef std::streamsize streamsize
;
30 typedef std::numeric_limits
<streamsize
> limits
;
32 buff() : count(0), buf() { }
36 // Number of characters left until we overflow the counter
37 const streamsize headroom
= limits::max() - count
;
40 return traits_type::eof();
45 count
= limits::max();
47 this->setg(buf
+ 1, buf
+ 1, buf
+ bufsz
);
52 int_type
overflow(int_type c
)
54 if (traits_type::eq_int_type(c
, traits_type::eof()))
56 this->setp(buf
, buf
+ bufsz
- 1);
57 return traits_type::not_eof(c
);
62 static const streamsize bufsz
= (2048 << limits::digits10
) + 1;
69 // Not possible to overflow 64-bit streamsize in reasonable time.
70 if (std::numeric_limits
<std::streamsize
>::digits
> 32)
73 std::basic_istream
<C
> in(new buff
);
76 VERIFY( in
.gcount() == std::numeric_limits
<std::streamsize
>::max() );
78 delete in
.rdbuf(new buff
);
81 VERIFY( in
.gcount() == 1 );
84 VERIFY( in
.gcount() == std::numeric_limits
<std::streamsize
>::max() );