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);
}
----
Comment #1 by clugdbug — 2012-01-26T00:15:08Z
This seems to be the same as bug 7231.
It reduces to:
struct Bug7324 {
void opDispatch()(){}
}
void func7234()
{
Bug7234 r;
if (r.xxx) {};
}
Comment #2 by bugzilla — 2012-01-28T20:48:41Z
(In reply to comment #1)
> It reduces to:
That doesn't seg fault, but the original does.
Comment #3 by github-bugzilla — 2012-01-28T23:22:31Z