Perhaps here is a critical bug of scope statement and scoped variable (RAII), please help me to veriry it

redsea redsea at 163.com
Tue Dec 16 21:02:41 PST 2008


error: 
    scope(success)  not called, and RAII variable not destruct correctly.

compiler:  Digital Mars D Compiler v1.033
come from tango-0.99.7-bin-linux-dmd.1.033.tar.gz

code:

import tango.io.Stdout;
alias Stdout ot;

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

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

    scope(exit)
        ot.flush;
    scope(failure)
        ot("doScan failure }}}").newline;
    scope(success)
        ot("doScan ok }}}").newline;

    scope auto ident__doScan__ident = new Indent();

    if (a == 0 )
        return;
}


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


output:

doScan {{{
<<<
doScan {{{
<<<
doScan {{{
<<<
doScan {{{
<<<
doScan {{{
<<<
doScan {{{
<<<
doScan {{{
<<<
doScan {{{
<<<




More information about the Digitalmars-d mailing list