← Back to index
|
Original Bugzilla link
Bug 12851 – ICE when passing const static array to template
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-06-04T04:59:00Z
Last change time
2014-06-07T22:38:02Z
Keywords
ice, pull
Assigned to
nobody
Creator
monkeyworks12
Comments
Comment #0
by monkeyworks12 — 2014-06-04T04:59:28Z
Related:
https://issues.dlang.org/show_bug.cgi?id=12850
The error given is: dmd: ctfeexpr.c:1741: Expression* ctfeIndex(Loc, Type*, Expression*, uinteger_t): Assertion `e1->op == TOKarrayliteral' failed. The code is only slightly different from Issue 12850.
http://dpaste.dzfl.pl/ef876e8a6cc9
Comment #1
by k.hara.pg — 2014-06-07T15:23:12Z
Please paste case code directly, or attach the source file. // From
http://dpaste.dzfl.pl/ef876e8a6cc9
template toTypeTuple(alias range) { import std.range : isInputRange; import std.traits : isArray, isNarrowString; import std.typetuple: TypeTuple; alias Arr = typeof(range); static if (isArray!Arr && !isNarrowString!Arr) { static if (range.length == 0) { alias toTypeTuple = TypeTuple!(); } else static if (range.length == 1) { alias toTypeTuple = TypeTuple!(range[0]); } else { alias toTypeTuple = TypeTuple!(toTypeTuple!(range[0 .. $/2]), toTypeTuple!(range[$/2 .. $])); } } else static if (isInputRange!Arr) { import std.array : array; alias toTypeTuple = toTypeTuple!(array(range)); } else { import std.string : format; static assert (0, format("Cannot transform %s of type %s into a TypeTuple.", range, Arr.stringof)); } } template staticZip(alias values, Indices...) { import std.typetuple; template Pair(T...) if (T.length == 2) { alias Pair = TypeTuple!(T); } static if (Indices.length == 1 && values.length == 1) { alias staticZip = TypeTuple!(Pair!(Indices[0], values[0])); } else { alias staticZip = TypeTuple!(Pair!(Indices[0], values[0]), staticZip!(Indices[1..$], values[1..$])); } } struct Index(int upperBound) if (upperBound > 0) { import std.range; enum range = toTypeTuple!(iota(upperBound)); enum length = range.length; alias rangeType = typeof(range[0]); alias rangeType this; } alias N = Index!5; void main() { import std.typetuple; const int[5] arr; pragma(msg, staticZip!(arr, N)); }
Comment #2
by k.hara.pg — 2014-06-07T17:20:45Z
https://github.com/D-Programming-Language/dmd/pull/3641
Comment #3
by github-bugzilla — 2014-06-07T22:38:02Z
Commits pushed to master at
https://github.com/D-Programming-Language/dmd
https://github.com/D-Programming-Language/dmd/commit/fa7e0b7ed522cdad458ccb1054ff7b43ae0b201a
fix Issue 12851 - ICE when passing const static array to template
https://github.com/D-Programming-Language/dmd/commit/d0be546737f9345156bafa18b79c32e3ef9fe369
Merge pull request #3641 from 9rnsr/fix12851 Issue 12851 - ICE when passing const static array to template