[Issue 10929] New: [CTFE] Destructor errornously gets called on NRVO-ed structs?
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Aug 30 11:33:53 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10929
Summary: [CTFE] Destructor errornously gets called on NRVO-ed
structs?
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: critical
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: dmitry.olsh at gmail.com
--- Comment #0 from Dmitry Olshansky <dmitry.olsh at gmail.com> 2013-08-30 11:33:52 PDT ---
If CTFE did full copy with postblit and dtor-ed temporary it would be more or
less OK.. but instead it seemingly moves struct but calls dtor.
(this bug blocks development of std.regex, marking as critical)
Test case shows difference between R-T and C-T:
struct Destroyable{
this(this)
{
postblitCount++;
}
~this(){
payload = 0;
dtorCount++;
}
int payload;
int dtorCount;
int postblitCount;
}
auto make()
{
auto val = Destroyable(42, 0);
return val;
}
enum dg = (){
auto val = make();
assert(val.postblitCount == 0); //passes in both modes
assert(val.dtorCount == 1); //passes at CT -- WAT?
//at R-T the above assertion fails as expected
return 0;
};
enum test_me = dg();
int main(){
return dg();
};
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list