www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6319] New: Problem with prinft inside debug{} of pure function

reply d-bugmail puremagic.com writes:
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



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: -------
Jul 14 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6319




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: -------
Jul 14 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6319


changlon <changlon gmail.com> changed:

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



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

    at src/rt/lifetime.d:1154

    stackTop=0x7fffffffe260) at src/gc/gcx.d:2631

    at src/gc/gcx.d:2391

    at src/gc/gcx.d:1329


    at src/rt/dmain2.d:515

    dg=0x00000000004abbdc00007fffffffe4a0) at src/rt/dmain2.d:471

    at src/rt/dmain2.d:518

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 14 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6319





 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

     at src/rt/lifetime.d:1154

     stackTop=0x7fffffffe260) at src/gc/gcx.d:2631

     at src/gc/gcx.d:2391

     at src/gc/gcx.d:1329


     at src/rt/dmain2.d:515

     dg=0x00000000004abbdc00007fffffffe4a0) at src/rt/dmain2.d:471

     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: -------
Jul 14 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
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



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: -------
Jan 16 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6319


yebblies <yebblies gmail.com> changed:

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



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: -------
Jan 16 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6319




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


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: -------
Jan 17 2013
prev sibling parent d-bugmail puremagic.com writes:
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: -------
Jan 17 2013