digitalmars.D - Perhaps here is a critical bug of scope statement and scoped variable (RAII), please help me to veriry it
- redsea (53/53) Dec 16 2008 error:
- redsea (29/37) Dec 16 2008 If comment the following:
- Jarrett Billingsley (26/70) Dec 16 2008 I just tried with DMD 1.037, and I get the correct output:
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 {{{
<<<
Dec 16 2008
If comment the following:
if (a == 0 )
return;
output would be ok:
[tmp]root ./test
doScan {{{
<<<
doScan ok }}}
doScan {{{
<<<
doScan ok }}}
doScan {{{
<<<
doScan ok }}}
doScan {{{
<<<
doScan ok }}}
doScan {{{
<<<
doScan ok }}}
doScan {{{
<<<
doScan ok }}}
doScan {{{
<<<
doScan ok }}}
doScan {{{
<<<
doScan ok }}}
Dec 16 2008
On Wed, Dec 17, 2008 at 12:02 AM, redsea <redsea 163.com> wrote: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); }I just tried with DMD 1.037, and I get the correct output: doScan {{{ <<<doScan ok }}} doScan {{{ <<<doScan ok }}} doScan {{{ <<<doScan ok }}} doScan {{{ <<<doScan ok }}} doScan {{{ <<<doScan ok }}} doScan {{{ <<<doScan ok }}} doScan {{{ <<<doScan ok }}} doScan {{{ <<<doScan ok }}}
Dec 16 2008









redsea <redsea 163.com> 