Thread overview
[Issue 6344] New: CTFE: Assertion Failure in interpret.c
Jul 18, 2011
Andrej Mitrovic
Jul 18, 2011
kennytm@gmail.com
[Issue 6344] [CTFE] Assertion Failure in interpret.c when create an empty slice from null pointer
Jul 18, 2011
kennytm@gmail.com
Jul 22, 2011
Walter Bright
July 18, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6344

           Summary: CTFE: Assertion Failure in interpret.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-07-18 12:07:58 PDT ---
DMD 2.054, XP32:

import std.array;
import std.stdio;
import std.conv;
import std.traits;

enum Foo
{
    pre_x,
    pre_y,
    pre_z,
}

mixin(wrapEnum!(Foo)("NewEnum", "pre_"));  // fails

private string wrapEnum(Type)(string newName, string prefix)
{
    string result = "enum " ~ newName ~ " {";

    foreach (member; EnumMembers!Type)
    {
        result ~= to!string(member).replace(prefix, "") ~ ",";
    }

    return result ~ "}";
}

void main()
{
    // writeln(wrapEnum!(Foo)("NewEnum", "pre_"));  // writes: enum NewEnum
{x,y,z,}
}

Output:

Assertion failure: 'se->e1->op == TOKarrayliteral || se->e1->op == TOKstring' on line 4957 in file 'interpret.c'

abnormal program termination

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


kennytm@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kennytm@gmail.com


--- Comment #1 from kennytm@gmail.com 2011-07-18 13:01:40 PDT ---
First reduction:

--------------------------------
import std.array;

string rp(string subject) {
    auto app = appender!string();
    app.put(subject[0 .. 0]);
    auto m = app.data;
    return m;
}

enum e = rp("pre_x");
--------------------------------

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


kennytm@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code
            Summary|CTFE: Assertion Failure in  |[CTFE] Assertion Failure in
                   |interpret.c                 |interpret.c when create an
                   |                            |empty slice from null
                   |                            |pointer


--- Comment #2 from kennytm@gmail.com 2011-07-18 13:16:45 PDT ---
Ultimate cause: create an empty slice from a 'null' pointer.

----------------------
static assert({
    char* c = null;
    auto m = c[0..0];
    return true;
}());
----------------------

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


Walter Bright <bugzilla@digitalmars.com> changed:

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


--- Comment #3 from Walter Bright <bugzilla@digitalmars.com> 2011-07-21 20:33:57 PDT ---
https://github.com/D-Programming-Language/dmd/commit/3309fcddfbc4e445a3e418c31a49d157c33161aa

https://github.com/D-Programming-Language/dmd/commit/2ea02077de9498746f5abb0043dc6ae1e5accefc

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