D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 10070 - Unexpected exception-related program crash
Summary: Unexpected exception-related program crash
Status: REOPENED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P3 normal
Assignee: No Owner
URL:
Keywords: backend, wrong-code
Depends on:
Blocks:
 
Reported: 2013-05-12 13:11 UTC by bearophile_hugs
Modified: 2024-12-13 18:06 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2013-05-12 13:11:51 UTC
A small Java program found in a blog post:


class Flow {
    static public void main(String[] args) {
        for (int i = 0; i < 6; ++i) {
            System.out.println("Loop: " + i);

            try {
                try {
                    if (i == 3)
                        break;
                } finally {
                    if (i % 2 != 0)
                        throw new Exception("");
                }
            } catch (Exception e) {
                System.out.println("Caught");
            }
        }
    }
}


Its output:

Loop: 0
Loop: 1
Caught
Loop: 2
Loop: 3
Caught
Loop: 4
Loop: 5
Caught


A D translation:

import std.stdio;

void main() {
    foreach (i; 0 .. 6) {
        writeln("Loop: ", i);

        try {
            try {
                if (i == 3)
                    break;
            } finally {
                if (i % 2 != 0)
                    throw new Exception("");
            }
        } catch (Exception e) {
            writeln("Caught");
        }
    }
}


dmd 2.063beta prints:

Loop: 0
Loop: 1
Caught
Loop: 2
Loop: 3

And then it crashes.

Various people in D.learn and on IRC show that maybe this fails only on 32 bit Windows.
Comment 1 yebblies 2013-11-21 08:05:44 UTC
I can't reproduce this.
Comment 2 bearophile_hugs 2013-11-21 09:48:50 UTC
Reopened because the problem is still present, on Windows Vista 32 bit, dmd 2.065alpha. This issue was discussed on IRC with several persons.
Comment 3 Walter Bright 2020-09-15 07:30:03 UTC
It works on Win64 and fails on Win32.
Comment 4 dlangBugzillaToGithub 2024-12-13 18:06:51 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/18580

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB