Re: learn some d those days, can't understand the code here

2016-02-13 Thread Adam D. Ruppe via Digitalmars-d
On Friday, 12 February 2016 at 20:13:16 UTC, Junfeng wrote: seems the code try to allocate an array with size from.length, but after cast, the length at offset 0 will be 0, so assert fail(why dmd allow this cast here? I try use GC.malloc and cast in my small test app, dmd will error "Error:

Re: learn some d those days, can't understand the code here

2016-02-13 Thread sigod via Digitalmars-d
On Friday, 12 February 2016 at 20:13:16 UTC, Junfeng wrote: a quick search, seem we should write it like: t[] to = (cast(T*)allocator.allocate(T.sizeof * from.length))[0 .. from.length]); but after this modify, it will crash at to[] = from[]; Shouldn't you use [`makeArray`][0] in

learn some d those days, can't understand the code here

2016-02-12 Thread Junfeng via Digitalmars-d
Hi, Come here for help. what I doing is setup vim and use dcd for goto define, but sometimes dcd-server got crash, issue is here: https://github.com/Hackerpilot/DCD/issues/294 Then I build the debug version, and an assert error comes out: