This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Open status.

### 423. Effects of negative `streamsize` in iostreams

Section: 29 [input.output] Status: Open Submitter: Martin Sebor Opened: 2003-09-18 Last modified: 2018-12-09

Priority: 3

View all other issues in [input.output].

View all issues with Open status.

Discussion:

A third party test suite tries to exercise `istream::ignore(N)` with a negative value of `N` and expects that the implementation will treat `N` as if it were `0`. Our implementation asserts that (`N >= 0`) holds and aborts the test.

I can't find anything in section 27 that prohibits such values but I don't see what the effects of such calls should be, either (this applies to a number of unformatted input functions as well as some member functions of the `basic_streambuf` template).

[ 2009-07 Frankfurt ]

> This is related to LWG 255.

> Move to NAD Future.

[LEWG Kona 2017]

Recommend Open: We agree that we should require `N >= 0` for the selected functions

[2018-12-04 Reflector prioritization]

Set Priority to 3

Proposed resolution:

I propose that we add to each function in clause 27 that takes an argument, say `N`, of type `streamsize` a Requires clause saying that "`N >= 0`." The intent is to allow negative streamsize values in calls to `precision()` and `width()` but disallow it in calls to `streambuf::sgetn()`, `istream::ignore()`, or `ostream::write()`.

[Kona: The LWG agreed that this is probably what we want. However, we need a review to find all places where functions in clause 27 take arguments of type `streamsize` that shouldn't be allowed to go negative. Martin will do that review.]