Wiki Roadmap Timeline Tickets New Ticket Source Search Help / Guide About Trac Login

Ticket #308 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

A scope(exit) that throws gets executed twice.

Reported by: fvbommel Assigned to: ChristianK
Priority: major Milestone:
Component: backend Version: hg tip
Keywords: Cc:

Description

Test case:

module throwing_scope_exit;

extern(C) int printf(char*, ...);

long foo(ref int p) {
    scope(exit) {
        p++;
        throw new Object;
    }
    return 0;
}

void main() {
    int p = 0;
    try {
        foo(p);
        assert(0);
    } catch {
    }
    printf("Number of types scope(exit) was executed : %d\n", p);
    assert(p == 1);
}

Result:

$ ldc -run test.d
Number of types scope(exit) was executed : 2
tango.core.Exception.AssertException@test.d(21): Assertion failure

Change History

05/22/09 18:24:05 changed by ChristianK

  • status changed from new to closed.
  • resolution set to fixed.

Fixed in [1412].

Copyright © 2008, LDC Development Team.