Thread overview
[Issue 1087] New: Scope classes not destroyed in labeled statements in switches
Mar 30, 2007
d-bugmail
Apr 05, 2007
d-bugmail
Mar 19, 2009
d-bugmail
[Issue 1087] scope(exit) is ignored if preceded by a label
Sep 16, 2009
Don
May 29, 2010
Walter Bright
March 30, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1087

           Summary: Scope classes not destroyed in labeled statements in
                    switches
           Product: D
           Version: 1.010
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: jarrett.billingsley@gmail.com


Have a look:

scope class A
{
        ~this()
        {
                writefln("A dtor");
        }
}

void main()
{
        int x = 5;

        switch(x)
        {
                case 5:
                        scope a = new A();
                        scope(exit) writefln("exit");
                        writefln("five");
                        break;
        }

        switch(x)
        {
                case 5:
                        goto _something;

                _something:
                        scope a = new A();
                        scope(exit) writefln("exit");
                        writefln("something");
                        break;
        }
}

This outputs:

five
exit
A dtor
something
exit

You'll notice the first switch works correctly -- "five", then "exit", then "A
dtor" are printed, as expected.  But the second switch jumps to a label (common
when you have several cases which have a common ending code) inside the switch.
 In this case, the scope(exit) statement prints "exit", but the scope class's
dtor is never called.

Related to 1041?


-- 

April 05, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1087


thomas-dloop@kuehne.cn changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         OS/Version|Windows                     |All




------- Comment #1 from thomas-dloop@kuehne.cn  2007-04-05 05:28 -------
Added to DStress as http://dstress.kuehne.cn/run/s/scope_17_A.d http://dstress.kuehne.cn/run/s/scope_17_B.d http://dstress.kuehne.cn/run/s/scope_17_C.d http://dstress.kuehne.cn/run/s/scope_17_D.d


-- 

March 19, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=1087





------- Comment #2 from gide@nwawudu.com  2009-03-19 15:27 -------
import std.stdio;

void main() {
        start: // Comment this line.
            scope(exit)
                writefln("exit");
            writefln("Got Here");
}

'exit' is not output if start: label is present.
C:\> test
Got Here


-- 

September 16, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=1087


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug@yahoo.com.au
            Summary|Scope classes not destroyed |scope(exit) is ignored if
                   |in labeled statements in    |preceded by a label
                   |switches                    |
           Severity|normal                      |critical


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 29, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=1087


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |DUPLICATE


--- Comment #3 from Walter Bright <bugzilla@digitalmars.com> 2010-05-28 21:38:56 PDT ---
*** This issue has been marked as a duplicate of issue 1894 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------