[Issue 1887] New: compiler freeze on array of dyn. arrays with empty first initializer
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Mar 2 13:44:55 PST 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1887
Summary: compiler freeze on array of dyn. arrays with empty first
initializer
Product: D
Version: 2.011
Platform: PC
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: adolf.mathias at googlemail.com
The program at the end of this post causes dmd 2.011 to emit the messages
adjac.d(7): Error: cannot implicitly convert expression ([0]) of type int[1u]
to void[]
adjac.d(7): Error: cannot implicitly convert expression ([0,1]) of type int[2u]
to void[]
adjac.d(7): Error: cannot implicitly convert expression ([0,2]) of type int[2u]
to void[]
adjac.d(7): Error: cannot implicitly convert expression ([1,2]) of type int[2u]
to void[]
adjac.d(7): Error: cannot implicitly convert expression ([1,2,3,4]) of type
int[4u] to void[]
adjac.d(7): Error: cannot implicitly convert expression ([2,3,5]) of type
int[3u] to void[]
adjac.d(7): Error: cannot implicitly convert expression ([4,5,6]) of type
int[3u] to void[]
and then to freeze. After replacing the invariant declaration, dmd 1.027 gives
me the same messages but terminates.
I unfortunately have to set the first element in the initializer of neighbors
to something else than [], and then after initialization, use the out-commented
length modification. Don't know whether that behavior is according to the
specs...
// http://www.ocf.berkeley.edu/~wwu/riddles/medium.shtml adjacency grid
import std.stdio;
void main() {
invariant int maxi = 8;
int[][maxi] neighbors = [ [ ], [ 0 ], [ 0, 1], [ 0, 2], [1, 2], [1, 2, 3, 4],
[ 2, 3, 5], [ 4, 5, 6 ] ];
int[maxi] grid;
// neighbors[0].length = 0;
void place(int k, uint mask)
{ if(k<maxi) {
for(uint m = 1, d = 1; d <= maxi; d++, m<<=1)
if(!(mask & m)) {
bool ok = true;
int dif;
foreach(nb; neighbors[k])
if((dif=grid[nb]-d)==1 || dif==-1) {
ok = false; break;
}
if(ok) {
grid[k] = d;
place(k+1, mask | m);
}
}
} else {
writef(" %d\n%d %d %d\n%d %d %d\n %d\n\n",
grid[0], grid[1], grid[2], grid[3], grid[4], grid[5], grid[6],
grid[7]);
}
}
place(0, 0);
}
--
More information about the Digitalmars-d-bugs
mailing list