www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7900] New: CTFE Internal error with -inline and associative arrays

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7900

           Summary: CTFE Internal error with -inline and associative
                    arrays
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: brian-schott cox.net



Reduced test case created with Dustmite and a bit of hand-editing:

--------------------------------

import std.range;

class Trie(K, V)
{
    void add(K key, V val)
    {
        Trie!(K,V) current = this;
        foreach(keyPart; key)
        {
            current.children[keyPart] = new Trie!(K, V);
        }
    }
    Trie!(K,V)[ElementType!K] children;
}

string fun(string[] args ...)
{
    auto t = new Trie!(string, string);
    t.add(args[0], "");
    foreach(v; t.children)
        if (v.children.length) {}
    return "";
}

void main()
{
    mixin(fun("=", "TokenType.assign"));
}

--------------------------------

testcase.d(21): Error: CTFE internal error: illegal value ��D.children

dmd: interpret.c:6678: void VarDeclaration::setValue(Expression*): Assertion
`isCtfeValueValid(newval)' failed.
Aborted

-------------------------------

No, that garbage in the error message is not a copy-paste error. It's different
each time I try to build, which leads me to suspect that something in the
compiler was uninitialized.

Possibly related: changing line 21 to foreach(v; t.children.values) results in
this error:

dmd: interpret.c:5527: TypeAArray* toBuiltinAAType(Type*): Assertion `t->ty ==
Tstruct' failed.
Aborted

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 13 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7900


brian-schott cox.net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |CTFE, ice



I just realized that the dropdown options are out-of-date. I have reproduced
this on 2.059 and 2.058. The compile only fails with the -inline switch.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 13 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7900


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au




 I just realized that the dropdown options are out-of-date.
They are not out of date. They contain a lot of obsolete tags. Nobody should use anything other than D1, D2, D1&D2. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 16 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7900


SomeDude <lovelydear mailmetrash.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lovelydear mailmetrash.com
           Platform|x86_64                      |All
         OS/Version|Linux                       |All



PDT ---
Same issue on Win32 2.059. The windows version gives the file/line of the
assertion, though.

PS E:\DigitalMars\dmd2\samples> rdmd  -inline bug.d
bug.d(21): Error: CTFE internal error: illegal value P▄S.children

Assertion failure: 'isCtfeValueValid(newval)' on line 6678 in file
'interpret.c'

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 21 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7900




Using DMD from git (b488853f4d3617945851d5d0a2ac20ccb7dab631), the error
message now shows:

tmp.d(21): Error: CTFE internal error: illegal value TOK232.children

dmd: interpret.c:6884: void VarDeclaration::setValue(Expression*): Assertion
`isCtfeValueValid(newval)' failed.
Aborted

The corrupted output is now gone, so that's a good thing. Test case still
compiles without -inline and fails when it is present.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 04 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7900




2.60 error:

dmd: expression.c:1276: void expToCBuffer(OutBuffer*, HdrGenState*,
Expression*, PREC): Assertion `precedence[e->op] != PREC_zero' failed.
Aborted

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 02 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7900




Reduced test case:

class Trie {
    Trie[dchar] children;
}

int bug7900() {
    Trie t = new Trie;
    t.children['='] = new Trie;
    foreach(v; t.children)
       if (v.children.length) {}
    return 1;
}

static assert(bug7900());

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 06 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7900


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



This was fixed as side effect of a commit which eliminates all CTFE inlining
bugs:

https://github.com/D-Programming-Language/dmd/commit/4d9d227cca763985583bf05958ac1f45eef36eda

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