Bug 30196 - VLA and setjumplongjump exceptions
Summary: VLA and setjumplongjump exceptions
Status: RESOLVED DUPLICATE of bug 19774
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Keywords: EH, sjlj-eh, wrong-code
Depends on:
Reported: 2006-12-13 08:32 UTC by Jan Ringos
Modified: 2007-03-14 06:06 UTC (History)
3 users (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Jan Ringos 2006-12-13 08:32:57 UTC
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;
Comment 1 Andrew Pinski 2006-12-13 08:37:19 UTC
This is SJLJ related as it works just fine on x86-linux and powerpc-darwin both uses dwarf2 exceptions.
One should note that VLA are an extension to C++.
Comment 2 Joshua Conner 2007-03-13 23:55:01 UTC
I have a patch for this that I'm testing right now.
Comment 3 Danny Smith 2007-03-14 05:57:27 UTC
This is a duplicate of PR 19774

Comment 4 Andrew Pinski 2007-03-14 06:06:08 UTC

*** This bug has been marked as a duplicate of 19774 ***