Thread overview
[Issue 6319] New: Problem with prinft inside debug{} of pure function
Jul 15, 2011
changlon
Jul 15, 2011
changlon
[Issue 6319] debug's relaxed purity does not apply to nested scopes
Jan 16, 2013
yebblies
Jan 16, 2013
yebblies
Jan 18, 2013
Kenji Hara
July 15, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6319

           Summary: Problem with prinft inside debug{} of pure function
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: bearophile_hugs@eml.cc


--- Comment #0 from bearophile_hugs@eml.cc 2011-07-14 17:14:15 PDT ---
A D2 program:


import core.stdc.stdio;
void foo() pure {
    debug {
        if(true)
            printf("********");
    }
}
void main() {
    foo();
}


If I compile it with -debug I DMD 2.054 it shows:
test.d(5): Error: pure function 'foo' cannot call impure function 'printf'


If I remove the if(true) line the program compiles and runs correctly:


import core.stdc.stdio;
void foo() pure {
    debug {
        printf("********");
    }
}
void main() {
    foo();
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 15, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6319



--- Comment #1 from bearophile_hugs@eml.cc 2011-07-14 17:52:52 PDT ---
Until this bug gets fixed, a simple workaround is to just put the if() outside
the debug{}:


import core.stdc.stdio;
void foo() pure {
    if(true)
        debug {
            printf("********");
        }
}
void main() {
    foo();
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 15, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6319


changlon <changlon@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |changlon@gmail.com


--- Comment #2 from changlon <changlon@gmail.com> 2011-07-14 18:10:31 PDT ---
Starting program: /web/www/tmp/jade/jade2test
[Thread debugging using libthread_db enabled]
f = 0x4fc4b0,32, t = 0x713030,32, size = 1
f = 0x4fed20,176, t = 0x7ffff7ed5f00,176, size = 1
f = 0x4ff200,72, t = 0x71f490,72, size = 1
f = 0x4f8c10,64, t = 0x7ffff7ed8fc0,64, size = 1
f = 0x4f8d00,64, t = 0x7ffff7ed8f80,64, size = 1
f = 0x4f0880,12, t = 0x7ffff7ed9ff0,12, size = 1
f = 0x4f3920,56, t = 0x7ffff7ed8f00,56, size = 1
f = 0x4f3920,56, t = 0x7ffff7ed8ec0,56, size = 1
1 times use time = 1ms



Program received signal SIGSEGV, Segmentation fault.
0x00000000004cda08 in rt.lifetime.rt_finalize (p=0x7ffff729d000, det=false)
    at src/rt/lifetime.d:1154
1154                ClassInfo c = **pc;
(gdb) bt
#0  0x00000000004cda08 in rt.lifetime.rt_finalize (p=0x7ffff729d000, det=false)
    at src/rt/lifetime.d:1154
#1  0x00000000004cb1de in gc.gcx.Gcx.fullcollect (this=0x713060,
    stackTop=0x7fffffffe260) at src/gc/gcx.d:2631
#2  0x00000000004caaf3 in gc.gcx.Gcx.fullcollectshell (this=0x713060)
    at src/gc/gcx.d:2391
#3  0x00000000004c902b in gc.gcx.GC.fullCollectNoStack (this=0x713030)
    at src/gc/gcx.d:1329
#4  0x00000000004c721d in gc.gc.gc_term () at src/gc/gc.d:133
#5  0x00000000004abc4d in rt.dmain2.main.runAll (this=0x7fffffffe4a0)
    at src/rt/dmain2.d:515
#6  0x00000000004ab6f5 in rt.dmain2.main.tryExec (this=0x7fffffffe4a0,
    dg=0x00000000004abbdc00007fffffffe4a0) at src/rt/dmain2.d:471
#7  0x00000000004ab684 in rt.dmain2.main (argc=1, argv=0x7fffffffe588)
    at src/rt/dmain2.d:518

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 15, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6319



--- Comment #3 from changlon <changlon@gmail.com> 2011-07-14 18:11:45 PDT ---
(In reply to comment #2)
> Starting program: /web/www/tmp/jade/jade2test
> [Thread debugging using libthread_db enabled]
> f = 0x4fc4b0,32, t = 0x713030,32, size = 1
> f = 0x4fed20,176, t = 0x7ffff7ed5f00,176, size = 1
> f = 0x4ff200,72, t = 0x71f490,72, size = 1
> f = 0x4f8c10,64, t = 0x7ffff7ed8fc0,64, size = 1
> f = 0x4f8d00,64, t = 0x7ffff7ed8f80,64, size = 1
> f = 0x4f0880,12, t = 0x7ffff7ed9ff0,12, size = 1
> f = 0x4f3920,56, t = 0x7ffff7ed8f00,56, size = 1
> f = 0x4f3920,56, t = 0x7ffff7ed8ec0,56, size = 1
> 1 times use time = 1ms
> 
> 
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x00000000004cda08 in rt.lifetime.rt_finalize (p=0x7ffff729d000, det=false)
>     at src/rt/lifetime.d:1154
> 1154                ClassInfo c = **pc;
> (gdb) bt
> #0  0x00000000004cda08 in rt.lifetime.rt_finalize (p=0x7ffff729d000, det=false)
>     at src/rt/lifetime.d:1154
> #1  0x00000000004cb1de in gc.gcx.Gcx.fullcollect (this=0x713060,
>     stackTop=0x7fffffffe260) at src/gc/gcx.d:2631
> #2  0x00000000004caaf3 in gc.gcx.Gcx.fullcollectshell (this=0x713060)
>     at src/gc/gcx.d:2391
> #3  0x00000000004c902b in gc.gcx.GC.fullCollectNoStack (this=0x713030)
>     at src/gc/gcx.d:1329
> #4  0x00000000004c721d in gc.gc.gc_term () at src/gc/gc.d:133
> #5  0x00000000004abc4d in rt.dmain2.main.runAll (this=0x7fffffffe4a0)
>     at src/rt/dmain2.d:515
> #6  0x00000000004ab6f5 in rt.dmain2.main.tryExec (this=0x7fffffffe4a0,
>     dg=0x00000000004abbdc00007fffffffe4a0) at src/rt/dmain2.d:471
> #7  0x00000000004ab684 in rt.dmain2.main (argc=1, argv=0x7fffffffe588)
>     at src/rt/dmain2.d:518

sorry for my mistake, this is for bug 6014

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 16, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6319


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies@gmail.com
           Platform|x86                         |All
         AssignedTo|nobody@puremagic.com        |yebblies@gmail.com
            Summary|Problem with prinft inside  |debug's relaxed purity does
                   |debug{} of pure function    |not apply to nested scopes
         OS/Version|Windows                     |All


--- Comment #4 from yebblies <yebblies@gmail.com> 2013-01-17 00:27:22 EST ---
Reduced:

int x;

void main() pure
{
    debug
    {
        {
            x = 0;
        }
    }
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 16, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6319


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #5 from yebblies <yebblies@gmail.com> 2013-01-17 00:29:30 EST ---
https://github.com/D-Programming-Language/dmd/pull/1494

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 18, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6319



--- Comment #6 from github-bugzilla@puremagic.com 2013-01-17 17:23:07 PST ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/fc45fef72942938f2f386bb8daeab327eb7243de Fix Issue 6319 - debug's relaxed purity does not apply to nested scopes

https://github.com/D-Programming-Language/dmd/commit/66e53d9161bf23ee0a45c1de996731869dc9d6c4 Merge pull request #1494 from yebblies/issue6319

Fix Issue 6319 - debug's relaxed purity does not apply to nested scopes

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 18, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6319


Kenji Hara <k.hara.pg@gmail.com> changed:

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


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------