timon.gehr at gmx.ch
Tue Dec 20 07:26:09 PST 2011
On 12/19/2011 01:04 PM, Bear wrote:
> Using D1, I have a program that creates tons of float ; for performance
> reasons, I would like them to be uninitialized.
> I've tried replacing
> float f = new float[x];
> float f = cast(float)std.gc.malloc(x*4);
> Unfortunately I keep running into "Access violation" and sometimes "Array
> bounds error". I've tried adding
> setTypeInfo(typeid(float), f.ptr);
> and hasNoPointer(f.ptr);
> which didn't work.
> f = float.nan;
> solved the problem, but kinda defeats the purpose of using malloc...
> What am I doing wrong?
Are you using GDC?
If so, this is the workaround:
float f = (cast(float)std.gc.malloc(x*4))[0..x];
More information about the Digitalmars-d-learn