Perhaps here is a critical bug of scope statement and scoped variable (RAII), please help me to veriry it
Jarrett Billingsley
jarrett.billingsley at gmail.com
Tue Dec 16 21:11:43 PST 2008
On Wed, Dec 17, 2008 at 12:02 AM, redsea <redsea at 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 }}}
More information about the Digitalmars-d
mailing list