1300 – Issues with struct in compile-time function

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 1300 - Issues with struct in compile-time function
Summary: Issues with struct in compile-time function
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 Windows
: P2 blocker
Assignee: Walter Bright
URL:
Keywords:
Depends on:
Blocks:
Reported: 2007年06月30日 07:40 UTC by Max Samukha
Modified: 2014年02月16日 15:24 UTC (History)
0 users

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 2007年06月30日 07:40:03 UTC
May be related to 1204
struct Bar
{
 int x;
}
int foo()
{
 // Fails with 'Error: cannot cast int to Bar' if explicit initialization is omitted:
 Bar b = Bar.init;
 b.x = 1;
 b = bar(b); // Error: cannot evaluate foo() at compile time
 return b.x;
}
Bar bar(Bar b)
{
 return b;
}
void main(char[][] args)
{
 static x = foo();
}
Comment 1 Max Samukha 2007年06月30日 08:41:39 UTC
More test cases:
struct Bar
{
 int x;
}
int foo()
{
 Bar b = Bar.init;
 b.x = 100;
 for (size_t i = 0; i < b.x; i++) // b.x is the stumbling block here 
 {
 }
 b.x++; // fails while b.x = b.x + 1 works
 return b.x;
}
void main(char[][] args)
{
 static x = foo();
}
Comment 2 Walter Bright 2007年07月30日 15:48:32 UTC
Fixed DMD 1.019 and 2.003


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