www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2518] New: scope(success) not execuate and RAII variable destructor is not called

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2518

           Summary: scope(success) not execuate and RAII variable destructor
                    is not called
           Product: D
           Version: 1.023
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: redsea 163.com


error:
scope(success) is not execuated,
RAII variable destructor is not called, this bug is critical.

I wrote a phobos version test program, and found windows version of dmd is
correct, but not linux version.

I test dmd 1.038. 1.037, 1.023, all is wrong.

the test program is as following:

import std.stdio;
alias writefln ot;

scope class Indent
{
    this()
    {
        ot("<<<");
    }
    ~this()
    {
        ot(">>>");
    }
}

void doScan(int a)
{
    ot("doScan {{{");

    scope(exit)
        {}
    scope(failure)
        ot("doScan failure }}}");
    scope(success)
        ot("doScan ok }}}");

    scope auto ident__doScan__ident = new Indent();
    if (a == 0 )
        return;
}


void main()
{
    for (int i=0; i<8;i++)
        doScan(0);
}


comment the following lines,  result would be ok:

    if (a == 0 )
        return;


the error output: (copy from linux dmd 1.038, running on debian lenny)
[tmp]root ./t
doScan {{{
<<<
doScan {{{
<<<
doScan {{{
<<<
doScan {{{
<<<
doScan {{{
<<<
doScan {{{
<<<
doScan {{{
<<<
doScan {{{
<<<

the correct output (copy from windows dmd 1.038)
C:\TEMP>t.exe
doScan {{{
<<<



doScan {{{ <<<



doScan {{{ <<<



doScan {{{ <<<



doScan {{{ <<<



doScan {{{ <<<



doScan {{{ <<<



doScan {{{ <<<



-------- detail enviorment infomation: [tmp]root uname -a Linux debian-dev-testing 2.6.25.20-pm-mon-02 #1 Sun Dec 7 17:57:03 CST 2008 i686 GNU/Linux [tmp]root dmd -v Digital Mars D Compiler v1.038 Copyright (c) 1999-2008 by Digital Mars written by Walter Bright Documentation: http://www.digitalmars.com/d/1.0/index.html [tmp]root dmd -v t.d parse t semantic t import object (/root/dmd/bin/../src/phobos/object.d) import std.stdio (/root/dmd/bin/../src/phobos/std/stdio.d) import std.c.stdio (/root/dmd/bin/../src/phobos/std/c/stdio.d) import std.c.stddef (/root/dmd/bin/../src/phobos/std/c/stddef.d) import std.c.stdarg (/root/dmd/bin/../src/phobos/std/c/stdarg.d) import std.format (/root/dmd/bin/../src/phobos/std/format.d) import std.stdarg (/root/dmd/bin/../src/phobos/std/stdarg.d) import std.utf (/root/dmd/bin/../src/phobos/std/utf.d) import std.c.stdlib (/root/dmd/bin/../src/phobos/std/c/stdlib.d) import std.c.string (/root/dmd/bin/../src/phobos/std/c/string.d) import std.string (/root/dmd/bin/../src/phobos/std/string.d) import std.uni (/root/dmd/bin/../src/phobos/std/uni.d) import std.array (/root/dmd/bin/../src/phobos/std/array.d) import std.ctype (/root/dmd/bin/../src/phobos/std/ctype.d) import std.gc (/root/dmd/bin/../src/phobos/std/gc.d) import gcstats (/root/dmd/bin/../src/phobos/gcstats.d) import std.c.linux.linux (/root/dmd/bin/../src/phobos/std/c/linux/linux.d) import std.c.linux.linuxextern (/root/dmd/bin/../src/phobos/std/c/linux/linuxextern.d) import std.c.linux.pthread (/root/dmd/bin/../src/phobos/std/c/linux/pthread.d) import std.intrinsic (/root/dmd/bin/../src/phobos/std/intrinsic.d) semantic2 t semantic3 t code t function this function _dtor function doScan function main gcc t.o -o t -m32 -Xlinker -L/root/dmd/bin/../lib -lphobos -lpthread -lm --
Dec 16 2008
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2518


clugdbug yahoo.com.au changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #1 from clugdbug yahoo.com.au  2009-04-03 07:40 -------
Fixed DMD2.023 and DMD1.039


-- 
Apr 03 2009