Created on 1998-08-06.00:00:00 last changed 172 months ago
Rationale:
The LWG looked to two alternative wordings, and choose the proposed resolution as better standardese.
Proposed resolution:
In 27.6.1.3, paragraph 1, after the sentence that begins "If an exception is thrown...", add the following parenthetical comment: "(Exceptions thrown from basic_ios<>::clear() are not caught or rethrown.)"
The introduction to the section on unformatted input (27.6.1.3) says that every unformatted input function catches all exceptions that were thrown during input, sets badbit, and then conditionally rethrows the exception. That seems clear enough. Several of the specific functions, however, such as get() and read(), are documented in some circumstances as setting eofbit and/or failbit. (The standard notes, correctly, that setting eofbit or failbit can sometimes result in an exception being thrown.) The question: if one of these functions throws an exception triggered by setting failbit, is this an exception "thrown during input" and hence covered by 27.6.1.3, or does 27.6.1.3 only refer to a limited class of exceptions? Just to make this concrete, suppose you have the following snippet.
char buffer[N]; istream is; ... is.exceptions(istream::failbit); // Throw on failbit but not on badbit. is.read(buffer, N);
Now suppose we reach EOF before we've read N characters. What iostate bits can we expect to be set, and what exception (if any) will be thrown?
History | |||
---|---|---|---|
Date | User | Action | Args |
2010-10-21 18:28:33 | admin | set | messages: + msg142 |
2010-10-21 18:28:33 | admin | set | messages: + msg141 |
1998-08-06 00:00:00 | admin | create |