[Issue 12417] `toStringz` is fundamentally broken

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Mar 24 09:51:45 PDT 2015


https://issues.dlang.org/show_bug.cgi?id=12417

--- Comment #5 from John Colvin <john.loughran.colvin at gmail.com> ---
Well in that case we have a problem with all calls to C that follow this
pattern:

allocate some GC memory
pass a pointer to said memory to C
never refer to the memory again

as there is nothing to guarantee that there will be any reference held on the D
side during the execution of the C function and no guarantee about where the C
function will hold the reference during its execution. There will be cases
where the optimiser will play nice, but in general it has no obligation to
preserve a reference on the D side to memory that is never accessed again.

--


More information about the Digitalmars-d-bugs mailing list