June 13, 2010
Leandro Lucarella wrote:
> Andrei Alexandrescu, el 12 de junio a las 07:20 me escribiste:
>> Leandro Lucarella wrote:
>>> Andrei Alexandrescu, el 12 de junio a las 00:32 me escribiste:
>>>> BCS wrote:
>>>>> http://stackoverflow.com/questions/3024136/link-compatibility-between-c-and-d
>>>> I just posted an answer that contains a couple of news.
>>> As I said with your new RefCounted implementation, unless I'm missing
>>> something, there will be problems if you store pointers (or objects that
>>> have pointers) to the GC heap, as you never communicate with the GC.
>> Could you please give an example? Thanks!
> 
> I guess is clear from the suggestion by Walter, but basically you are
> not telling the GC about the roots outside the stack(s) and static data.
> If the GC can't reach an object from that roots, but those objects are
> still pointed by the malloc()ed memory, the GC will recycle the
> "dangling" objects (from the GC POV) and bad things will happen (memory
> corruption, basically).
> 
> I hope it clarifies.

Yes, thanks. Walter posted a conservative fix, we can improve it by defining hasIndirections which is a bit similar with hasAliasing:

http://www.digitalmars.com/d/2.0/phobos/std_traits.html#hasAliasing

Then the compiler decides statically to instruct the GC or not depending on hasIndirections.


Andrei
1 2
Next ›   Last »