1948 – CTFE fails when mutating a struct in an array

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 1948 - CTFE fails when mutating a struct in an array
Summary: CTFE fails when mutating a struct in an array
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: patch, rejects-valid
Depends on:
Blocks:
Reported: 2008年03月26日 12:47 UTC by Max Samukha
Modified: 2014年02月24日 15:32 UTC (History)
2 users (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Max Samukha 2008年03月26日 12:47:43 UTC
Error: cannot evaluate foo() at compile time
struct S
{
 int x;
}
int foo()
{
 S[] a = [];
 a ~= S();
 
 a[0].x = 1; // Fails 
 return 0;
}
enum x = foo();
Btw, CTFE is relatively difficult to debug. More informative messages than "cannot evaluate ... at compile time" would be appreciated.
Comment 1 Don 2009年02月19日 07:04:04 UTC
This applies to D1.0 as well.
For D1.0, change last line of test case to:
int x = foo();
Comment 2 Don 2009年07月24日 02:21:17 UTC
Patch included in patch for bug#2569.
Comment 3 Walter Bright 2009年09月03日 13:23:18 UTC
Fixed dmd 1.047 and 2.032


AltStyle によって変換されたページ (->オリジナル) /