Am 19.11.2011 21:49, schrieb Timon Gehr:
The fact that Nicks example works has no implications for the GC
implementation because the two types involved in his reinterpret-casting
don't have any indirections.
Furthermore:
int* a =...;
int b = cast(int)a;
int* c = cast(int*)b;
// assert(a == c); // not guaranteed!
The language allows the GC to move around heap data.
What kind of GC would be impossible to implement?
I am by no means a GC expert, but I was under the impression that D
could only make use of conservative GC because of the casting tricks.
What if Nick's example had inner pointers?
align(1) struct Foo
{
int x, y;
ubyte r, g, b, a;
char[16] ident;
uint[100] data;
Foo* next;
}
Is the GC smart enough to know that Foo.next will contain garbage after
the assignment with cast? What about when I later assign a valid value
to it?