D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4515 - Compiler crashes when accessing a static array returned by a function
Summary: Compiler crashes when accessing a static array returned by a function
Status: RESOLVED DUPLICATE of issue 4414
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Linux
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-26 21:56 UTC by Deokjae Lee
Modified: 2010-07-27 00:28 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Deokjae Lee 2010-07-26 21:56:27 UTC
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 Don 2010-07-27 00:28:48 UTC

*** This issue has been marked as a duplicate of issue 4414 ***