www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10311] New: gdb prints wrong value for variable updated from closure


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

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

void receive(void delegate(int n) dg)
    static int cnt;

void main()
    int loc1=10;
    int loc2=100;
        (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: -------
Jun 08 2013