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 #3 by bugzilla — 2013-10-06T23:14:46Z
(In reply to comment #2) > I get segfault on this (D2 only, 2.062, Linux/Windows): > > void main() > { > int[2] a; > a = cast(int[2])null; > } Fix for this only: https://github.com/D-Programming-Language/dmd/pull/2638
Comment #4 by github-bugzilla — 2013-10-08T21:13:26Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/9a8ca60f58d08926b1c623ab298371b064a7e60d fix Issue 8179 - ICE(e2ir.c) with failed fixed size array cast https://github.com/D-Programming-Language/dmd/commit/04dfab6cdd1c7e5bc6f512db058575faf4257226 Merge pull request #2638 from WalterBright/fix8179 fix Issue 8179 - ICE(e2ir.c) with failed fixed size array cast
Comment #5 by mk — 2013-10-22T05:32:55Z
Reopening, since the code from original description and comment 1 were not fixed (comment 1 part 2 does work though).
Comment #6 by bugzilla — 2013-11-12T20:00:48Z
Comment #7 by github-bugzilla — 2013-11-13T20:35:51Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/88b0e504d6b13e3707e6f0d904ee6bf9e1a5236c fix Issue 8179 - ICE(e2ir.c) with failed fixed size array cast https://github.com/D-Programming-Language/dmd/commit/66216b55c5b40a50c503963532f882d611fa7500 Merge pull request #2752 from WalterBright/fix8179b fix Issue 8179 - ICE(e2ir.c) with failed fixed size array cast
Comment #8 by github-bugzilla — 2015-01-14T21:17:09Z
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/7a1a5d53c887401a2c3b44da1dff87c2f90f04c0 Disallow casting typeof(null) <--> Tsarray And this is the generalized fix for the issue 8179 case. In NullExp::castTo(), we can just rely on the TypeNull:implicitConvTo() behavior.
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