6015 – [CTFE] Strange behavior of assignment appears in a situation

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6015 - [CTFE] Strange behavior of assignment appears in a situation
Summary: [CTFE] Strange behavior of assignment appears in a situation
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
Reported: 2011年05月16日 00:45 UTC by Hisayuki Mima
Modified: 2011年05月18日 21:24 UTC (History)
1 user (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 Hisayuki Mima 2011年05月16日 00:45:47 UTC
struct Foo{
 string field;
}
bool func(string input){
 Foo foo;
 foo.field = input[0..$];
 assert(foo.field == "test");
 foo.field = "test2";//assignment1
 assert(foo.field == "test");//assertion1
 assert(foo.field == "test2");//assertion2
 return true;
}
static assert(func("test"));
This code doesn't work on dmd v2.053.
Somehow assertion1 succeeds and somehow assertion2 fails in CTFE.
This shows that assignment1 has wrong behavior.


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