Bug 9540 – Compiler crash on delegate context frame assignment

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-02-19T16:31:00Z
Last change time
2013-04-23T02:18:57Z
Keywords
ice, pull
Assigned to
nobody
Creator
casantander1

Attachments

IDFilenameSummaryContent-TypeSize
1193failure.dtest casetext/plain504

Comments

Comment #0 by casantander1 — 2013-02-19T16:31:35Z
I'm trying to write a particular template, and once I got to a certain point, I got DMD to crash. I'm attaching the file with the offending code. The compiler output is: > Assertion failed: (0), function totym, file glue.c, line 1235. > Abort trap: 6 I tested this with DMD 2.061 on WIndows and Mac OS X.
Comment #1 by casantander1 — 2013-02-19T16:32:15Z
Created attachment 1193 test case
Comment #2 by maxim — 2013-02-20T03:45:03Z
That's because Type::totym() during object file generation got Terror value, which is not switched. Error message can be improved by checking for such value and printing usual error, but the real problem is that Terror escaped frontend.
Comment #3 by maxim — 2013-02-20T03:46:04Z
(In reply to comment #0) > > Assertion failed: (0), function totym, file glue.c, line 1235. > > Abort trap: 6 > > I tested this with DMD 2.061 on WIndows and Mac OS X. Can confirm on linux githead.
Comment #4 by maxim — 2013-02-20T05:27:24Z
Reduced: module failure; template Tuple(E...) { alias E Tuple; } alias Tuple!(int) Args; void main() { (new A).test (); } void test1 (int delegate (int) f) { f (-2); } class A { int f (int a) { return a; } void test () { test1 (&AddFront!(this, f)); } } template AddFront (alias ctx, alias fun) { auto AddFront(Args args) { auto dg (Args dgArgs) { return fun (dgArgs); } dg.ptr = ctx; return dg(args); } }
Comment #5 by dmitry.olsh — 2013-04-14T05:24:43Z
Nice job at reduction. I'm hitting the same issue while trying to integrate new std.uni into Phobos but the circumstances are different. I'm certainly not trying to do anything funky with delegate pointers. The message is the same for me (both with your minimal test and when compiling anything in my fork of phobos): dmd: glue.c:1215: virtual unsigned int Type::totym(): Assertion `0' failed. Aborted Now if only dustmite didn't crush on it... we'd have another case.
Comment #6 by k.hara.pg — 2013-04-22T23:03:48Z
https://github.com/D-Programming-Language/dmd/pull/1911 The root cause is wrong semantic error gagging for UFCS resolving.
Comment #7 by github-bugzilla — 2013-04-22T23:55:54Z
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/7c2cea2eee75690a6239b5afb53f76c82fc41ecd fix Issue 9540 - Compiler crash on delegate context frame assignment
Comment #8 by k.hara.pg — 2013-04-23T02:18:57Z
Now the reduced code reports following errors. test.d(26): Error: function test.A.test.AddFront!(this, f).AddFront.dg (int _param_0) is not callable using argument types () test.d(17): Error: template instance test.A.test.AddFront!(this, f) error instantiating auto dg (Args dgArgs) { return fun (dgArgs); } dg.ptr = ctx; // <-- line 26 dg is not a delegate, it is a nested function. So it does not have `ptr` property.