D issues are now
tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Summary: |
[CTFE] Assertion Failure in interpret.c when create an empty slice from null pointer |
Product: |
D
|
Reporter: |
Andrej Mitrovic <andrej.mitrovich> |
Component: |
dmd | Assignee: |
No Owner <nobody> |
Status: |
RESOLVED
FIXED
|
Severity: |
major
|
CC: |
bugzilla, kennytm
|
Priority: |
P2
|
Keywords: |
ice-on-valid-code |
Version: |
D2 |
Hardware: |
Other |
OS: |
Windows |
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
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");
--------------------------------
Ultimate cause: create an empty slice from a 'null' pointer.
----------------------
static assert({
char* c = null;
auto m = c[0..0];
return true;
}());
----------------------