This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/66139] destructor not called for members of partially constructed anonymous struct/array
- From: "jaak at ristioja dot ee" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 10 May 2017 13:04:05 +0000
- Subject: [Bug c++/66139] destructor not called for members of partially constructed anonymous struct/array
- Auto-submitted: auto-generated
- References: <bug-66139-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66139
Jaak Ristioja <jaak at ristioja dot ee> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jaak at ristioja dot ee
--- Comment #9 from Jaak Ristioja <jaak at ristioja dot ee> ---
According to a Stack Overflow answer [1] this bug occurs when the constructor
is the first thing executed in the try-block. For example:
#include <iostream>
struct A { A(int e) { throw e; } };
struct B {
A a{42}; // Same with = 42; syntax
};
int main() {
try {
// Remove this printout line to trigger the bug:
std::cout << "Welcome" << std::endl;
B b;
} catch (int e) {
return e;
}
}
[1]: http://stackoverflow.com/a/43892501/3919155