[Issue 10311] New: gdb prints wrong value for variable updated from closure

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jun 8 16:39:52 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10311

           Summary: gdb prints wrong value for variable updated from
                    closure
           Product: D
           Version: D2
          Platform: All
        OS/Version: Linux
            Status: NEW
          Keywords: symdeb
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: mk at krej.cz


--- Comment #0 from Martin Krejcirik <mk at krej.cz> 2013-06-09 01:39:51 CEST ---
import std.stdio;

void receive(void delegate(int n) dg)
{
    static int cnt;
    dg(++cnt);
}

void main()
{
    int loc1=10;
    int loc2=100;
    loc1++;
    receive(
        (int n) { loc2++; writeln("received ", n); }
    );
    writefln("loc: %d %d", loc1, loc2); /* prints 11 101 */
    /* run gdb, breakpoint at line 17
    (gdb) p loc1
    $1 = 11
    (gdb) p loc2
    $1 = 0
    */
}

dmd 2.063+, x86, linux, gdb 7.3, compiled dmd -gc

As you can see, variable loc2, which is incremented inside the function
literal, shows wrong value by gdb print.

Quite annoying, I use code like this with std.concurrency and it's impossible
to debug (without writef's);

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


More information about the Digitalmars-d-bugs mailing list