Thread overview
[Issue 6774] New: Assertion failure: '0' on line 1117 in file 'glue.c'
Oct 05, 2011
Andrej Mitrovic
Oct 06, 2011
Kenji Hara
[Issue 6774] ICE(glue.c) totym gagged forward reference error
Dec 26, 2011
David Simcha
Apr 20, 2012
Andrej Mitrovic
Jun 14, 2012
Roman D. Boiko
Jun 14, 2012
Roman D. Boiko
Nov 15, 2012
Don
Oct 06, 2013
Walter Bright
Oct 06, 2013
Andrej Mitrovic
October 05, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6774

           Summary: Assertion failure: '0' on line 1117 in file 'glue.c'
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: andrej.mitrovich@gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2011-10-05 16:56:46 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 06, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6774


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-invalid-code


--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2011-10-06 13:58:09 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 26, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6774


David Simcha <dsimcha@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dsimcha@yahoo.com
            Summary|ICE(glue.c) gagged forward  |ICE(glue.c) totym gagged
                   |reference error             |forward reference error


--- Comment #2 from David Simcha <dsimcha@yahoo.com> 2011-12-26 07:57:41 PST ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 20, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6774



--- Comment #4 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-04-19 18:55:30 PDT ---
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'

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 14, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6774


Roman D. Boiko <rb@d-coding.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rb@d-coding.com


--- Comment #5 from Roman D. Boiko <rb@d-coding.com> 2012-06-14 10:22:27 PDT ---
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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 14, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6774



--- Comment #6 from Roman D. Boiko <rb@d-coding.com> 2012-06-14 10:26:37 PDT ---
(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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 15, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6774



--- Comment #7 from Don <clugdbug@yahoo.com.au> 2012-11-14 23:55:13 PST ---
Reduced test case for comment 5:
----
void foo(T)(ref immutable(T) data) {}

void test6774() {
  immutable a = 2.0f;
  foo!(float)(a);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 06, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6774


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |WORKSFORME


--- Comment #8 from Walter Bright <bugzilla@digitalmars.com> 2013-10-05 20:26:52 PDT ---
(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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 06, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6774



--- Comment #9 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-10-06 06:06:53 PDT ---
Kenji or others, can you confirmed this was deliberately fixed? We should add it to the test-suite if not (it affects multiple people).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------