std library hooks

Artur Skawina art.08.09 at gmail.com
Sun Apr 15 13:15:51 PDT 2012


On 04/15/12 22:05, Artur Skawina wrote:
> You *can* ignore the conflict, eg in the ld case just add
> "-Wl,--allow-multiple-definition" to the DFLAGS, don't use LTO, and it will
> let you do things like:
> 
>    extern (C) void* gc_malloc(int) { assert(0); }
>    
>    import std.stdio;
>    void main(string[] argv) {
>       string s1 = argv[0];
>       s1 = "*" ~ s1;
>       writeln(s1);
>    }
> 
> which will trigger the assert when the array op tries to allocate memory.

Actually, it will assert as soon as the druntime tries its first allocation,
ie way before "main" is reached; you'd need to make the first few malloc calls,
that are done before user code gets to run, work.

artur


More information about the Digitalmars-d mailing list