https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68213
Bug ID: 68213 Summary: Exception handling corrupts a VLA in MinGW Product: gcc Version: 5.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: hedayat.fwd at gmail dot com Target Milestone: --- Code: ----------------------------------------------------------------- #include <iostream> #include <cstring> #include <sstream> #include <stdexcept> using namespace std; int main(int argc, char **argv) { int n; stringstream ss(argv[1]); ss >> n; cout << "N: " << n << endl; char tbuff[n]; try { memset(tbuff, 0, n); throw runtime_error("ERR"); } catch (exception &e) { cout << "Writing to VLA" << endl; memset(tbuff, 0, n); cout << "Wrote" << endl; } } ----------------------------------------------------------------- Compiled with: /usr/bin/i686-w64-mingw32-g++ -O2 test.cpp -o t Run with wine (similar results under Windows) results in crash: []% ./t 100 fixme:winediag:start_process Wine Staging is a testing version containing experimental patches. fixme:winediag:start_process Please report bugs at http://bugs.wine-staging.com (instead of winehq.org). N: 100 Writing to VLA wine: Unhandled page fault on read access to 0x00000000 at address (nil) (thread 0009), starting debugger... Unhandled exception: page fault on read access to 0x00000000 in 32-bit code (0x00000000). ....