[dmd-internals] phobos fails with the new compiler

Andrei Alexandrescu andrei at erdani.com
Mon Jan 25 06:52:36 PST 2010


With the new beta, unittests in std.stdio fail. Apparently this is 
because the unittests run before static module initialization takes place.

std.stdio relies on std.stdiobase to perform static initialization. The 
latter module defines

static this()
{
     std_stdio_static_this();
}

and in turn that calls:

extern(C) void std_stdio_static_this()
{
     //printf("std_stdio_static_this()\n");

     //Bind stdin, stdout, stderr
     __gshared File.Impl stdinImpl;
     stdinImpl.handle = core.stdc.stdio.stdin;
     .stdin.p = &stdinImpl;
     // stdout
     __gshared File.Impl stdoutImpl;
     stdoutImpl.handle = core.stdc.stdio.stdout;
     .stdout.p = &stdoutImpl;
     // stderr
     __gshared File.Impl stderrImpl;
     stderrImpl.handle = core.stdc.stdio.stderr;
     .stderr.p = &stderrImpl;
}

This function is not called (I uncommented the printf). The unittests 
are then invoked, and one of them checks whether std.stdio.stdin was 
initialized properly.

Walter, did you change something in module initialization?


Andrei


More information about the dmd-internals mailing list