On Sunday, 22 October 2017 at 15:21:37 UTC, Shriramana Sharma wrote:
For my program right now I'm using a souped-up version using a static array:

    char[20] name = "/tmp/XXXXXX";

Hmm I was wondering if I needed it to be static, and verily, substituting:

char[] name = "/tmp/XXXXXX".dup;

instead gives a proper output *some* of the time but mostly gives the error:

std.exception.ErrnoException@std/stdio.d(630): (Bad file descriptor)
----------------
??:? @safe shared(core.stdc.stdio._IO_FILE)* std.exception.errnoEnforce!(shared(core.stdc.stdio._IO_FILE)*, "std/stdio.d", 630uL).errnoEnforce(shared(core.stdc.stdio._IO_FILE)*, lazy immutable(char)[]) [0x44bd31] ??:? @trusted void std.stdio.File.fdopen(int, const(char[]), immutable(char)[]) [0x44294a] ??:? @safe void std.stdio.File.fdopen(int, const(char[])) [0x4428b1]
??:? <src>.TempFile <src>.tempFileOpen() [0x43d4fd]
??:? _Dmain [0x43d5ce]

Is it because the D slice is subject to relocation and C is occasionally not able to access the proper pointer?

Reply via email to