← Back to index
|
Original Bugzilla link
Bug 13827 – [REG2.067a] Internal Compiler Error: null field
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-12-07T12:49:00Z
Last change time
2015-02-18T03:40:58Z
Keywords
CTFE, ice, pull
Assigned to
nobody
Creator
temtaime
Comments
Comment #0
by temtaime — 2014-12-07T12:49:59Z
mixin template VectorImpl() { this(A...)(auto ref in A args) { uint k; foreach(ref v; args) flat[k++] = cast(T)v; } } struct Matrix(T, uint _M, uint _N = _M) { enum { M = _M, //rows N = _N, //columns C = M * N, // count of elements isVector = N == 1 || M == 1, } private static defaultMatrix() { T arr[M][N] = void; foreach(i, ref v; arr) { v[] = 0; static if(M == N) v[i] = 1; } return arr; } union { T[N][M] A = defaultMatrix; T[C] flat; } mixin VectorImpl; } alias Vector(T, uint M) = Matrix!(T, 1, M); alias Vector3 = Vector!(float, 3); enum isMatrix(T) = is(T == Matrix!A, A...); template isVector(T) { static if(isMatrix!T) enum isVector = T.isVector; else enum isVector = false; } enum S = Vector3(1, 2, 3); void main() { } main.d(6): Error: Internal Compiler Error: null field flat main.d(6): Error: cannot determine length of this.flat at compile time main.d(50): called from here: Matrix([[0.000000F, 0.000000F, 0.000000F]], ).this(1, 2, 3) Maybe one can reduce it more. This code compiles on 2.066.
Comment #1
by temtaime — 2014-12-07T12:53:43Z
Reduced more: struct Matrix(T, uint N) { private static defaultMatrix() { T arr[N]; return arr; } union { T[N] A = defaultMatrix; T[N] flat; } this(A...)(auto ref in A args) { uint k; foreach(ref v; args) flat[k++] = cast(T)v; } } enum S = Matrix!(int, 3)(1, 2, 3);
Comment #2
by ketmar — 2014-12-07T13:05:24Z
struct Matrix(T) { private static defaultMatrix() { T arr[3]; return arr; } union { T[3] A = defaultMatrix; T[3] flat; } this (T v) { flat[0] = v; } } enum S = Matrix!int(42);
Comment #3
by ketmar — 2014-12-07T13:06:11Z
p.s. i'm not even sure that this is supposed to work in compile-time.
Comment #4
by temtaime — 2014-12-07T13:08:07Z
Thanks. It worked in 2.066. :) P.S. +1 for 42
Comment #5
by k.hara.pg — 2014-12-09T12:55:06Z
https://github.com/D-Programming-Language/dmd/pull/4204
Comment #6
by github-bugzilla — 2014-12-11T01:47:40Z
Commits pushed to master at
https://github.com/D-Programming-Language/dmd
https://github.com/D-Programming-Language/dmd/commit/40bc59344366188d089e2495aaac371c6f8193c4
fix Issue 13827 - Internal Compiler Error: null field
https://github.com/D-Programming-Language/dmd/commit/95e4aa85d70c66dc859f504c10530770580d4ddd
Merge pull request #4204 from 9rnsr/fix13827 [REG2.067a] Issue 13827 - Internal Compiler Error: null field
Comment #7
by github-bugzilla — 2015-02-18T03:40:58Z
Commits pushed to 2.067 at
https://github.com/D-Programming-Language/dmd
https://github.com/D-Programming-Language/dmd/commit/40bc59344366188d089e2495aaac371c6f8193c4
fix Issue 13827 - Internal Compiler Error: null field
https://github.com/D-Programming-Language/dmd/commit/95e4aa85d70c66dc859f504c10530770580d4ddd
Merge pull request #4204 from 9rnsr/fix13827