Dealing with the interior pointers bug

ag0aep6g via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jun 21 12:25:55 PDT 2017


On 06/21/2017 07:23 PM, H. S. Teoh via Digitalmars-d-learn wrote:
> Being a systems programming language means you should be able to do
> things outside the type system (in @system code, of course, not in @safe
> code), including storing pointers as int values.  Any C code that your D
> program interoperates with may also potentially do similar things.

The GC doesn't scan the C heap. You didn't say that it does, but it 
might be understood that way.

> Because of this, the GC cannot simply assume that an int value isn't
> actually a pointer value in disguise, so if that int value happens to
> coincide with an address of an allocated memory block, the only sane
> thing it can do is to assume the worst and assume that the memory is
> still live (via that (assumed) reference).

There are cases where the GC does assume that ints are not pointers. For 
example, an int[] on the GC heap won't be scanned for pointers. The GC 
is neither completely precise nor completely conservative.


More information about the Digitalmars-d-learn mailing list