Bug 8506 – segault when using map with template delegate
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-08-04T04:54:00Z
Last change time
2012-10-26T11:45:18Z
Assigned to
nobody
Creator
deadalnix
Comments
Comment #0 by deadalnix — 2012-08-04T04:54:03Z
import std.algorithm;
import std.array;
class A {
B[] b;
}
class B {}
void main() {
A a;
a.b = a.b.map!(b => b)().array();
}
This code segfault in invariant._d_invariant with dmd 2.060 . This ork fine with (B b) { return b; } as delegate.
Comment #1 by k.hara.pg — 2012-08-04T10:22:27Z
(In reply to comment #0)
> import std.algorithm;
> import std.array;
>
> class A {
> B[] b;
> }
>
> class B {}
>
> void main() {
> A a;
>
> a.b = a.b.map!(b => b)().array();
> }
>
> This code segfault in invariant._d_invariant with dmd 2.060 . This ork fine
> with (B b) { return b; } as delegate.
The variable a is class, and initialized with null, then this code never works.
Comment #2 by deadalnix — 2012-08-04T10:57:04Z
(In reply to comment #1)
> (In reply to comment #0)
> > import std.algorithm;
> > import std.array;
> >
> > class A {
> > B[] b;
> > }
> >
> > class B {}
> >
> > void main() {
> > A a;
> >
> > a.b = a.b.map!(b => b)().array();
> > }
> >
> > This code segfault in invariant._d_invariant with dmd 2.060 . This ork fine
> > with (B b) { return b; } as delegate.
>
> The variable a is class, and initialized with null, then this code never works.
Ooops, it seems I failed to reduce the bug to a simple case (I actually introduced a new problem of my own, you are right). And if I initialize a, the segfault don't occur. This bug report is invalid, I'll create a new one with some help of dustmite.