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

### 863. What is the state of a stream after close() succeeds

Section: 31.10 [file.streams] Status: NAD Submitter: Steve Clamage Opened: 2008-07-08 Last modified: 2017-06-15

Priority: Not Prioritized

View all other issues in [file.streams].

View all issues with NAD status.

Discussion:

Suppose writing to an `[o]fstream` fails and you later close the `stream`. The `overflow()` function is called to flush the buffer (if it exists). Then the file is unconditionally closed, as if by calling `flcose`.

If either `overflow` or `fclose` fails, `close()` reports failure, and clearly the `stream` should be in a failed or bad state.

Suppose the buffer is empty or non-existent (so that `overflow()` does not fail), and `fclose` succeeds. The `close()` function reports success, but what is the state of the `stream`?

[ Batavia (2009-05): ]

> Tom's impression is that the issue is about the `failbit`, etc.

> Bill responds that the stream is now closed, and any status bits remain unchanged.

> See the description of `close()` in 31.10.5.4 [fstream.members].

> We prefer not to add wording to say that nothing changes. Move to NAD.

Proposed resolution: