In the code below the compiler will "Segmentation fault." getopt takes a string[], but is being given just a string. With the included import to std.c.linux.linux DMD will end with a segfault rather than the appropriate error message. Removing the import works as expected. import std.c.linux.linux; import std.getopt; string arg1; void main(string[] args) { } void parseArgs(ref string args) { getopt(args, "f|file", &arg1); }
Can someone please (1) check that this fails; and (2) reduce the test case? Need to work out which part of std.c.linux.linux is triggering it. Probably isn't Linux specific, unless it's crashing in the code generation step.
Reduced test case. Applies on any OS (not Linux specific), but D2 only since it involves overload sets. Import order is important! If order of imports is swapped, generates "Error: expected 1 function arguments, not 0". Segfaulting in CallExp::semantic(). e1->type is garbage. (not NULL, garbage!) ---- import bugB; import bugC; void main() { foo(); } ---- bugB.d: ---- void foo(int) {} --- bugC.d: --- void foo(T)(){}
ANALYSIS: expression.c, line 6693: if (!f) { /* No overload matches, just set f and rely on error * message being generated later. */ f = (FuncDeclaration *)eo->vars->a.data[0]; } This is wrong because it's not necessarily a FuncDeclaration, it could be a TemplateDeclaration instead. I think an error message needs to be generated immediately. Change this to something like: if (!f) { /* No overload matches, just set f and rely on error * message being generated later. */ error("no overload matches %s", savedFuncName); return this; } after having added to line 6320 something like: istemp = 0; Lagain: + char *savedFuncName = toChars(); //printf("Lagain: %s\n", toChars()); f = NULL; if (e1->op == TOKthis || e1->op == TOKsuper) { // semantic() run later for these } else { UnaExp::semantic(sc); since the UnaExp::semantic() call turns the name into __overloadset which makes yucky error messages.
Fixed dmd 2.034