[Issue 7234] New: Segmentation fault when using stdio

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jan 5 11:46:13 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=7234

           Summary: Segmentation fault when using stdio
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: robert at octarineparrot.com


--- Comment #0 from Robert Clipsham <robert at octarineparrot.com> 2012-01-05 19:46:11 GMT ---
The following test case is invalid code, but it is reproducible using valid
code (DustMite caused some issues here while narrowing down phobos). It
segfaults with dmd 2.057 on both Ubuntu 32 and OS X 64. I've included a comment
for how to get a valid code test case, it depends on phobos though!
----
template isInputRange(R) {
    enum bool isInputRange = is(typeof({ R r; if (r.empty) {} }));
}

void formattedWrite(Writer, Char, A...)(Writer w, in Char, A args) {
    foreach (i, arg; args)
        i= &formatGeneric!(Writer, typeof(arg), Char);
}

struct FormatSpec(Char) {}

void formatValue(Writer, T, Char)(Writer w, T val, ref FormatSpec!Char f) if
(!isInputRange!T) {
}

private void formatGeneric(Writer, D, Char)(Writer w, const(void)* arg, ref
FormatSpec!Char f) {
    formatValue(w, *cast(D*) arg, f);
}
struct File {
    void writefln(S...)(S args) {
        auto w = LockingTextWriter();
        formattedWrite(w, args);
    }

    struct LockingTextWriter {}
}

File stdout;

// You can replace the above with import std.stdio; and
// give the opDispatch below a valid signature to gain a
// valid code test case, it's rather large though!
struct Contract {
    void opDispatch()(){}
}
Contract*mOptional;
void populate()
{
    stdout.writefln("opt   : %s", mOptional);
}
----

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list