Bug 4414 – ICE(cgcs.c) Taking item of static array returned by function

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-07-01T16:13:00Z
Last change time
2013-04-07T10:56:01Z
Keywords
ice
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2010-07-01T16:13:32Z
int[1] foo() { return [0]; } void main() { int x = foo()[0]; } DMD 2.047 gives: Internal error: ..\ztc\cgcs.c 359
Comment #1 by clugdbug — 2010-07-27T00:28:48Z
*** Issue 4515 has been marked as a duplicate of this issue. ***
Comment #2 by andrej.mitrovich — 2010-08-29T19:52:03Z
This passes: import std.stdio : writeln; int[1] foo() { return [0]; } void main() { int x = foo()[0]; writeln(typeid(x)); // writes int //~ writeln(x); } But if I uncomment the last line then I get a different error: Internal error: ..\ztc\cod2.c 4494
Comment #3 by andrej.mitrovich — 2010-08-29T19:52:22Z
I forgot to mention this is on 2.048.
Comment #4 by d-bugzilla — 2010-11-16T03:41:16Z
(Digital Mars D Compiler v2.050) I have a variation on this theme: int f(lazy int[2] iarr) { return iarr[1]; } void main() { int[2] iarr; f(iarr); } Internal error: ../ztc/cgcs.c 359 It works if I remove the lazy keyword. Of course, lazy is quite meaningless in this context, but anyhow.
Comment #5 by kennytm — 2011-03-19T16:47:22Z
*** Issue 5755 has been marked as a duplicate of this issue. ***
Comment #6 by zetetyck — 2011-11-16T06:59:55Z
To make searching easier, I just want to mention that with DMD 2.056, this code: int[1] foo() { return [0]; } void main() { int x = foo()[0]; } Now gives: Internal error: ..\ztc\cgcs.c 352
Comment #7 by issues.dlang — 2012-06-06T01:21:52Z
Still fails on pre-2.060 HEAD with Internal error: backend/cgcs.c 343
Comment #8 by clugdbug — 2012-09-13T07:49:33Z
*** Issue 8627 has been marked as a duplicate of this issue. ***
Comment #9 by yebblies — 2012-12-26T05:39:58Z
*** Issue 8159 has been marked as a duplicate of this issue. ***
Comment #10 by yebblies — 2012-12-26T05:40:35Z
Same thing happens with slicing ubyte[4] bytes() { ubyte[4] x; return x; } void main() { auto x = bytes()[0..4]; }
Comment #11 by bugzilla — 2013-04-07T01:13:14Z
Comment #12 by github-bugzilla — 2013-04-07T03:11:56Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/024aa349664d7232056b7f28d07b6595c505d448 fix Issue 4414 - ICE(cgcs.c) Taking item of static array returned by function https://github.com/D-Programming-Language/dmd/commit/aa767b0d7fe1616010a6caf205918f29aa4560a1 Merge pull request #1858 from WalterBright/fix4414 fix Issue 4414 - ICE(cgcs.c) Taking item of static array returned by function
Comment #13 by github-bugzilla — 2013-04-07T10:56:01Z
Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/11bf7c8071a058cb441163ee58a4daf3f4b86de4 Merge pull request #1858 from WalterBright/fix4414 fix Issue 4414 - ICE(cgcs.c) Taking item of static array returned by function