digitalmars.D.bugs - [Issue 4869] New: auto return + inheritance + modules = compiler crashes
- d-bugmail puremagic.com (31/31) Sep 14 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4869
- d-bugmail puremagic.com (10/10) Sep 14 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4869
- d-bugmail puremagic.com (18/18) Sep 14 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4869
- d-bugmail puremagic.com (29/29) Sep 14 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4869
- d-bugmail puremagic.com (27/27) Sep 15 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4869
- d-bugmail puremagic.com (12/12) Sep 22 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4869
http://d.puremagic.com/issues/show_bug.cgi?id=4869 Summary: auto return + inheritance + modules = compiler crashes Product: D Version: D2 Platform: Other OS/Version: Windows Status: NEW Keywords: ice-on-valid-code Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: dsimcha yahoo.com The following code crashes both DMD 2.048 and 2.049 beta on Windows: // Module a.d class Base { auto fun() { return 1; } } // Module b.d import a; class Derived : Base {} // Command dmd -c b.d Any of the following will prevent this bug from being reproduced: 1. Changing the return type of fun from auto to int. 2. Passing both modules to DMD at once. 3. Putting both classes in the same module. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 14 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4869 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |clugdbug yahoo.com.au Not a regression. This fails on 2.026 and later. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 14 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4869 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|auto return + inheritance + |auto return + inheritance + |modules = compiler crashes |modules = compiler | |crashes(toctype.c) The segfault should be turned into an ICE with this code: toctype.c, line 254 TypeFunction::toCtype() if (varargs != 1) t->Tflags |= TFfixed; ctype = t; + assert(next); t->Tnext = next->toCtype(); -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 14 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4869 This is happening because semantic3() isn't run on the base class function. Bug 3602 has a similar root cause. A workaround is to use the function in module b.d. This forces semantic3 to be run on 'fun'. void workaround(Derived d) { auto k = d.fun(); } Mitigation patch (turns it into rejects-valid): --------- tocsym.c, line 349, FuncDeclaration::toSymbol() s = symbol_calloc(id); slist_add(s); + // Ensure function has a return value + if (type->ty == Tfunction && !((TypeFunction *)type)->next) + { + error("Internal Compiler Error. See Bugzilla 4869."); + // Prevent a later crash + ((TypeFunction *)type)->next = Type::tint32; + } { s->prettyIdent = toPrettyChars(); s->Sclass = SCglobal; symbol_func(s); -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 14 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4869 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch Proper patch. The assert in comment 2 should still be added. toobj.c line 790. ClassDeclaration::toObjFile(). Ensure each function has had semantic3 run on it, if the return type is still unknown. (Ideally, this should happen earlier on, but better late than never). for (; i < vtbl.dim; i++) { FuncDeclaration *fd = ((Dsymbol *)vtbl.data[i])->isFuncDeclaration(); //printf("\tvtbl[%d] = %p\n", i, fd); if (fd && (fd->fbody || !isAbstract())) { + // Ensure function has a return value (Bugzilla 4869) + if (fd->type->ty == Tfunction && !((TypeFunction *)fd->type)->next) + { + assert(fd->scope); + fd->semantic3(fd->scope); + } Symbol *s = fd->toSymbol(); -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 15 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4869 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla digitalmars.com Resolution| |FIXED 16:18:38 PDT --- http://www.dsource.org/projects/dmd/changeset/684 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 22 2010