What's wrong with this code?
just at ask.me
Sat Jan 8 12:46:15 PST 2011
Sean Eskapp napisał(a):
> I had some code that was segfaulting, so I rewrote the basic idea as a
> fibonacci function, and lo and behold, it still segfaults. Why, and how
> to fix?
This looks fishy:
private const Fib* left, right;
this(in Fib left, in Fib right)
this.left = &left;
this.right = &right;
Are you sure you want a pointer to class? Classes have reference semantics
in D (like Java). Structs are value types, though. Anyway, it looks like
the ctor takes the address of the reference placed on the stack.
More information about the Digitalmars-d-learn