Bug 6774 – ICE(glue.c) totym gagged forward reference error

Status
RESOLVED
Resolution
WORKSFORME
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-10-05T16:56:00Z
Last change time
2013-10-06T06:06:53Z
Keywords
ice
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2011-10-05T16:56:46Z
This is derived from a ~2000 line module, I'm beat: import std.traits; struct PointImpl(T) { @property auto test() { return PointImpl!int(); } } struct Wrapper(T) { T payload; auto test() { static if (is(ReturnType!(T.test) == void)) { } return payload.test; } } Wrapper!(PointImpl!int) point; void main() { auto x = point.test; } It's hard to explain the point of this code like this, but anyway I get back: Assertion failure: '0' on line 1117 in file 'glue.c' If I remove the `static if` statement the assertion goes away. I also had some Expression assertion errors, but it's too damn tiring to produce a minimal test-case.
Comment #1 by k.hara.pg — 2011-10-06T13:58:09Z
Remove dependency to std.traits. ---- private template staticLength(tuple...) { enum size_t staticLength = tuple.length; } template ReturnType(func...) if (staticLength!(func) == 1) // (a) { static if (is(typeof(func) R == return)) alias R ReturnType; else static assert(0, "argument has no return type"); } struct PointImpl(T) { @property auto test() { return PointImpl!int(); } } struct Wrapper(T) { T payload; auto test() { //pragma(msg, ReturnType!(T.test)); //static if (is(ReturnType!(T.test))) { } static if (is(ReturnType!(T.test) == void)) { } return payload.test; } } Wrapper!(PointImpl!int) point; void main() { auto x = point.test; } ---- A gagged forward reference error at (a) causes this problem.
Comment #2 by dsimcha — 2011-12-26T07:57:41Z
I just spent a bunch of time reducing a test case only to then stumble on this duplicate bug. To add some detail so that anyone who runs into it in the future can find it, the ICE error message is: glue.c:1065: virtual unsigned int Type::totym(): Assertion `0' failed.
Comment #3 by soul8o8 — 2012-01-04T11:44:46Z
I've run into this as well. Reproduce: // - - - - - 8< - - - - // a.d module a; import b; void main(){ auto m = new A; } class A { enum ENUM = 1337; MissingClass[1] missing; this(){ foreach(m; missing) m = new B; } } // - - - - - - -8< - - - - // b.d module b; import a; class B { ushort foo = A.ENUM; } // - - - - - - 8< - - - - $ dmd a.d b.d $ ./a $ dmd -g a.d b.d Assertion failed: (0), function totym, file glue.c, line 1065. Abort trap: 6 $ _ DMD64 D Compiler v2.057 (OSX 10.7.2) *** Note that in one case assigning an object to a variable of an undefined data type is compiled without error and even a functioning binary is produced (!) *** I consider this bug very serious and I think it should be "critical", as producing binaries that uses undefined data types without error is not just spectacularly frustrating but potentially harmful. (But I'll leave it to someone else to decide.)
Comment #4 by andrej.mitrovich — 2012-04-19T18:55:30Z
Updates: OP sample works in 2.057+. Kenji's sample works in 2.059. Heywood's sample still ICEs, except it seems to ice regardless of the -g flag: Assertion failure: '0' on line 1114 in file 'glue.c'
Comment #5 by rb — 2012-06-14T10:22:27Z
struct S(T) { pure nothrow static void foo(immutable(T) data) {} pure nothrow static void foo(ref immutable(T) data) {} } unittest { immutable a = 2.0f; S!float.foo(a); } compiler is run with the following flags: -m64 -w -debug -gc -fPIC -unittest on Ubuntu 12.10 x64. Result: Error: 2 is not an lvalue dmd: glue.c:1114: virtual unsigned int Type::totym(): Assertion `0' failed. Aborted (core dumped) make: *** [build/client] Error 134
Comment #6 by rb — 2012-06-14T10:26:37Z
(In reply to comment #5) > compiler is run with the following flags: > -m64 -w -debug -gc -fPIC -unittest Actually, -unittest is enough, other flags don't affect the result.
Comment #7 by clugdbug — 2012-11-14T23:55:13Z
Reduced test case for comment 5: ---- void foo(T)(ref immutable(T) data) {} void test6774() { immutable a = 2.0f; foo!(float)(a); }
Comment #8 by bugzilla — 2013-10-05T20:26:52Z
(In reply to comment #7) > Reduced test case for comment 5: > ---- > void foo(T)(ref immutable(T) data) {} > > void test6774() { > immutable a = 2.0f; > foo!(float)(a); > } This compiles without error on 2.064 head.
Comment #9 by andrej.mitrovich — 2013-10-06T06:06:53Z
Kenji or others, can you confirmed this was deliberately fixed? We should add it to the test-suite if not (it affects multiple people).