www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - bug of scope (linux only) verified, Critical

reply redsea <redsea 163.com> writes:
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 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
next sibling parent reply Brad Roberts <braddr puremagic.com> writes:
redsea wrote:
<trim bug report>

The proper place to report bugs is bugzilla:

   http://d.puremagic.com/issues/

Thanks,
Brad
Dec 16 2008
parent reply redsea <redsea 163.com> writes:
Brad Roberts Wrote:

 redsea wrote:
 <trim bug report>
 
 The proper place to report bugs is bugzilla:
 
    http://d.puremagic.com/issues/
 
 Thanks,
 Brad
Thanks, I report it, Issue 2518. Hope it could be fixed quickly. I post this bug it here first because of I feel this bug is very critical, would cause many weired fails, not so easy to debug, so maybe post it here, and let more people know it, is better. If if disturb you, forgive me. Today I rewrite many code to avoid return in the middle of the function, otherwise my RAII mechanism would fail. But some function is difficult to rewrite.
Dec 16 2008
parent reply Christopher Wright <dhasenan gmail.com> writes:
redsea wrote:
 I post this bug it here first because of I feel this bug is very critical,
would cause many weired fails,  not so easy to debug, so maybe post it here,
and let more people know it, is better.
I sympathize with this, but when you are reporting a bug that no one else has, and it's been around for a while, you could conclude that it's not critical to very many people. That said, once it's on bugzilla, people can vote for it to encourage Walter to look at it sooner.
Dec 17 2008
parent redsea <redsea 163.com> writes:
Christopher Wright Wrote:

 redsea wrote:
 I post this bug it here first because of I feel this bug is very critical,
would cause many weired fails,  not so easy to debug, so maybe post it here,
and let more people know it, is better.
I sympathize with this, but when you are reporting a bug that no one else has, and it's been around for a while, you could conclude that it's not critical to very many people. That said, once it's on bugzilla, people can vote for it to encourage Walter to look at it sooner.
Ok, I see. I would do as you said next time. Thanks.
Dec 17 2008
prev sibling next sibling parent redsea <redsea 163.com> writes:
detail enviorment infomation:

[tmp]root uname -a

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 

[tmp]root ./t
doScan {{{
<<<
doScan {{{
<<<
doScan {{{
<<<
doScan {{{
<<<
doScan {{{
<<<
doScan {{{
<<<
doScan {{{
<<<
doScan {{{
<<<

[tmp]root cat t.d
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);
}
Dec 16 2008
prev sibling parent reply "Jarrett Billingsley" <jarrett.billingsley gmail.com> writes:
On Wed, Dec 17, 2008 at 1:56 AM, redsea <redsea 163.com> wrote:
 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.
Ah, so it is platform-specific!
Dec 17 2008
parent davidl <davidl 126.com> writes:
在 Wed, 17 Dec 2008 22:15:51 +0800,Jarrett Billingsley
<jarrett.billingsley gmail.com> 写道:

 On Wed, Dec 17, 2008 at 1:56 AM, redsea <redsea 163.com> wrote:
 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.
Ah, so it is platform-specific!
That's why I insisted he try his dmd 1.037 previously.
Dec 17 2008