D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3281 - ICE(cod1.c) append returned struct to array
Summary: ICE(cod1.c) append returned struct to array
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Linux
: P2 normal
Assignee: No Owner
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2009-09-02 09:41 UTC by pc
Modified: 2015-06-09 01:28 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description pc 2009-09-02 09:41:02 UTC
import std.stdio;

struct S {string s; this(string x){s=x;}}

immutable(S) mkS(){
  return S("mks hi");
}

void main(char[][] args) {
  immutable(S) s = mkS();
  immutable(S)[] ss;
  ss ~= S("plain hi");
  ss ~= cast(immutable(S)) S("plain hi");
  //ss ~=  mkS(); // --> "Internal error: ../ztc/cod1.c 1684"
  writeln(s.s, ", ", ss[0].s);
}


I think (hope?) this is all valid code. I.e.,

  ss ~= S("Hi"); //should be ok
  ss.length = ss.length + 1;
  ss[$-1] = S("plain hi"); //should fail to compile (as it indeed does)

In any case there is an ICE.



 
Error: ss[0] isn't mutable
Error: ss[0] isn't mutable

  //ss[0] = S("fail"); --> Error: ss[0] isn't mutable
Comment 1 Don 2009-09-02 12:19:08 UTC
Good news: This is already fixed in DMD 2.032, which will hopefully be released tomorrow.
Comment 2 Walter Bright 2009-09-03 13:46:02 UTC
Fixed dmd 2.032