Bug 8179 – ICE(e2ir.c) with failed fixed size array cast
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-06-01T13:22:00Z
Last change time
2015-02-18T03:42:33Z
Keywords
ice, pull
Assigned to
nobody
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2012-06-01T13:22:58Z
struct Foo {
static void opCall(int[2][1]) {}
}
void main() {
Foo(cast(int[2][1])[1, 2]);
}
DMD 2.060alpha gives:
test.d(5): Error: e2ir: cannot cast [1,2] of type int[] to type int[2u][1u]
Internal error: e2ir.c 155
Comment #1 by bearophile_hugs — 2012-10-18T03:20:07Z
A simpler test case shows it's not related to opCall, so I have updated the title:
void foo(int[2][1]) {}
void main() {
foo(cast(int[2][1])[1, 2]);
}
----------------------------
A similar but not equal case (arrays are 1D):
void foo(int[2] data) {}
void main() {
int[4] data;
int[2] data2 = data[0 .. 2]; // OK
foo(data2); // OK
foo(cast(int[2])data[0 .. 2]); // Internal error
}
test.d(6): Error: e2ir: cannot cast data[0u..2u] of type int[] to type int[2u]
Internal error: e2ir.c 189
Comment #2 by mk — 2013-04-02T16:13:22Z
I get segfault on this (D2 only, 2.062, Linux/Windows):
void main()
{
int[2] a;
a = cast(int[2])null;
}
Comment #9 by bearophile_hugs — 2015-01-14T23:03:50Z
This reduction of the original example:
void main() /*@nogc*/ {
int[2][1] m = cast(int[2][1])[1, 2];
}
still doesn't compile:
test2.d(2,34): Error: e2ir: cannot cast [1, 2] of type int[] to type int[2][1]
Do you want me to reopen this issue?
Comment #10 by k.hara.pg — 2015-01-15T02:04:05Z
(In reply to bearophile_hugs from comment #9)
> This reduction of the original example:
>
> void main() /*@nogc*/ {
> int[2][1] m = cast(int[2][1])[1, 2];
> }
>
>
> still doesn't compile:
>
> test2.d(2,34): Error: e2ir: cannot cast [1, 2] of type int[] to type
> int[2][1]
>
> Do you want me to reopen this issue?
It's a dup of issue 7514.
Comment #11 by github-bugzilla — 2015-02-18T03:42:33Z