Bug 4515 – Compiler crashes when accessing a static array returned by a function
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Linux
Creation time
2010-07-26T21:56:00Z
Last change time
2010-07-27T00:28:48Z
Assigned to
nobody
Creator
asitdepends
Comments
Comment #0 by asitdepends — 2010-07-26T21:56:27Z
import std.stdio;
struct S {
int[1] get() {
return x;
}
private int[1] x;
}
void main() {
S s;
writeln(s.get()[0]);//This line crashes dmd2
}
Dmd 2.047 produces the following message:
Internal error: ../ztc/cod2.c 4333
It seems that the compiler works properly when the array size is larger than 2.
Dynamic arrays also work well.
I tried a workaround like this.
auto x = s.get()[0];
writeln(x);//This line crashes the compiler
However, this cannot fix the problem.
The last line crashes the compiler.
Same message is produced by the code.
Comment #1 by clugdbug — 2010-07-27T00:28:48Z
*** This issue has been marked as a duplicate of issue 4414 ***