I found this interesting thing. The "array" content is destroyed after the
"catch" statement but it shouldn't be. It behaves the same in MinGW 4.2.0 and
3.4.4 for me. It seems like the "array" is unwound out when the exception is
caught.
---
#include <cstdlib>
#include <cstdio>
#include <stdexcept>
int main () {
int n = 10;
int array [n];
for (int i = 0; i < n; ++i) array [i] = i;
try {
for (int i = 0; i < n; ++i) std::printf ("%u,", array [i]);
std::printf (" = %u\n", n);
throw 1;
} catch (int) {
for (int i = 0; i < n; ++i) std::printf ("%u,", array [i]);
std::printf (" = %u\n", n);
};
return 0;
};
--
Summary: Variable-length automatic array contents gets destroyed
on unrelated exception
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: Tringi at Mx-3 dot cz
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30196