GC.BlkAttr.FINALIZE
Namespace
rswhite4 at googlemail.com
Mon Mar 3 15:38:47 PST 2014
> It sounds suspicious. Clearly, you are not accessing a1 there,
> and clearly a1 is set before being used.
>
> Any chance to reduce it?
>
> -Steve
I don't know. But I know that my little trick doesn't work in
lifetime.d although it works locally. Here what I tried:
----
import std.stdio;
struct Foo {
int id;
}
void main() {
Foo[] fs;
fs ~= Foo(45);
fs ~= Foo(46);
fs ~= Foo(47);
fs ~= Foo(48);
auto ti = typeid(fs);
writeln("&ti = ", &ti);
void* p = fs.ptr;
void[] arr = *cast(void[]*) p;
void* tp = cast(void*)((&arr) - cast(void*) 8);
TypeInfo ti2 = *cast(TypeInfo*) tp;
writeln(ti, " versus ", ti2);
}
----
Since rt_finalize and the GC have the same pointer as 'fs.ptr' I
cast it to an array struct. From the pointer of this struct I
subtract 8 (8 because of try and error until the pointer was
equal the real TypeInfo pointer). This I can cast to the
TypeInfo: it works. But not in lifetime.d. Was a try, but I have
no idea why it doesn't work (the pointers aren't equal). An idea
or alternative?
More information about the Digitalmars-d-learn
mailing list