Bug 9834 – incorrect detection of lambda locality.
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-03-30T04:49:00Z
Last change time
2015-02-23T06:45:05Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
zan77137
Comments
Comment #0 by zan77137 — 2013-03-30T04:49:12Z
This code makes AccessViolation on git master head:
-------------------
struct Event()
{
void delegate() dg;
void set(void delegate() handler)
{
dg = handler;
}
void call()
{
dg();
}
}
void main()
{
Event!() ev;
auto a = new class
{
Object o;
this()
{
o = new Object;
ev.set((){o.toString();});
}
};
ev.call();
}
-------------------
$ dmd -run main
object.Error: Access Violation
----------------
0x004020A5
0x00402128
0x00402057
0x004029EC
0x00402A27
0x00402625
0x00402140
0x769133AA in BaseThreadInitThunk
0x774E9EF2 in RtlInitializeExceptionChain
0x774E9EC5 in RtlInitializeExceptionChain
And, following is git bisect result:
$ git bisect bad
67fbf5753e9d4a276c354e952ed2f888efcb714c is the first bad commit
Comment #1 by k.hara.pg — 2013-03-30T12:13:10Z
(In reply to comment #0)
> And, following is git bisect result:
> $ git bisect bad
> 67fbf5753e9d4a276c354e952ed2f888efcb714c is the first bad commit
The commit is not a root cause.
If change Event struct to non-template, and add pure to set method, AV still occurs.
struct Event {
void delegate() dg;
//void set(void delegate() h) { dg = h; } // no AV
void set(void delegate() h) pure { dg = h; } // AV occurs
void call() { dg(); }
}
void main() {
Event ev;
auto a = new class {
Object o;
this() {
o = new Object;
ev.set((){ o.toString(); });
}
};
ev.call();
}