Created on 2015-09-28.00:00:00 last changed 112 months ago
Proposed resolution (February, 2016):
Change 14.3 [except.ctor] paragraph 2 as follows:
The destructor is invoked for each automatic object of class type constructed since the try block was entered. The
automaticobjects are destroyed in the reverse order of the completion of their construction.
[Adopted at the February, 2016 meeting.]
Consider the following example:
#include <stdio.h>
struct X {
X() { puts("X()"); }
X(const X&) { puts("X(const X&)"); }
~X() { puts("~X()"); }
};
struct Y { ~Y() noexcept(false) { throw 0; } };
X f() {
try {
Y y;
return {};
} catch (...) {
}
return {};
}
int main() {
f();
}
Current implementations print X() twice but ~X() only once. That is obviously wrong, but it is not clear that the current wording covers this case.
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2017-02-06 00:00:00 | admin | set | status: tentatively ready -> cd4 |
| 2016-02-15 00:00:00 | admin | set | messages: + msg5696 |
| 2016-02-15 00:00:00 | admin | set | status: drafting -> tentatively ready |
| 2015-09-28 00:00:00 | admin | create | |