digitalmars.D.bugs - [Issue 4500] New: scoped moves class after calling the constructor
- d-bugmail puremagic.com (32/32) Jul 23 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4500
- d-bugmail puremagic.com (10/10) Jul 25 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4500
- d-bugmail puremagic.com (43/43) Jul 26 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4500
- d-bugmail puremagic.com (8/8) Jul 26 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4500
- d-bugmail puremagic.com (10/10) Jul 26 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4500
- d-bugmail puremagic.com (9/9) Mar 23 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4500
- d-bugmail puremagic.com (11/16) Mar 23 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4500
- d-bugmail puremagic.com (6/6) Mar 26 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4500
- d-bugmail puremagic.com (10/10) Jul 17 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4500
- d-bugmail puremagic.com (10/10) Sep 07 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4500
http://d.puremagic.com/issues/show_bug.cgi?id=4500 Summary: scoped moves class after calling the constructor Product: D Version: D2 Platform: Other OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: andrei metalanguage.com ReportedBy: kamm-removethis incasoftware.de 23:59:57 PDT --- As far as I remember a class is not supposed to move. class A { this() { a = this; } this(int i) { a = this; } A a; void check() { writeln(this is a); } } void main() { auto a1 = scoped!A; a1.check(); // fails auto a2 = scoped!A(1); a2.check(); // fails a1.a = a1; a1.check(); // ok now } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 23 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4500 Andrei Alexandrescu <andrei metalanguage.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED 09:48:34 PDT --- Thanks for the catch! This is a serious problem indeed. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 25 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4500 Max Samukha <samukha voliacable.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |samukha voliacable.com PDT --- I didn't know D structs were allowed to be moved without calling the copy constructor. Is it really the case? FWIW, modern C++ implementations would optimize the copy out. For example, the following C++ test passes with a recent GNU C++: template <typename T> class Scoped { char data[sizeof(T)]; public: T* payload() { return reinterpret_cast<T*>(data); } Scoped(int i) { new(payload()) T(i); } ~Scoped() { payload()->~T(); } }; template <typename T> Scoped<T> scoped(int i) { Scoped<T> s(i); return s; } class A { public: A() { a = this; } A(int i) { a = this; } A *a; void check() { std::cout << (this == a ? "true" : "false") << std::endl; } ~A() { std::cout << "~A dtor" << std::endl; } }; int main(int argc, char *argv[]) { Scoped<A> a2 = scoped<A>(1); a2.payload()->check(); // ok } Anyway, it is not reasonable to base a fundamental feature like 'scoped' on RVO without having the latter in the language specification. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 26 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4500 03:19:53 PDT --- The language specifies that returning a stack-allocated object by value from a function does not invoke the constructor. Currently the compiler is not up to the specification. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 26 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4500 PDT --- But does it specify that the object should not be moved? Currently, the struct is constructed on the callee's frame and then blitted (moved) to the caller's frame, though the compiler can optimize the blit out (as GNU C++ does). If this kind of RVO is not specified, obviously 'scoped' cannot rely on it and will remain broken even if dmd will eventually be able to apply the optimization. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 26 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4500 Created an attachment (id=933) Fixed scoped I tried to fix this issue. It succeeded, but resulting code includes ugly hack. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 23 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4500 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |k.hara.pg gmail.comCreated an attachment (id=933) [details] Fixed scoped I tried to fix this issue. It succeeded, but resulting code includes ugly hack.I worked on 64bit Windows 7. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 23 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4500 I posted issue 5777 and attached experimental dmd patch. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 26 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4500 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch https://github.com/D-Programming-Language/phobos/pull/148 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 17 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4500 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED CC| |bugzilla digitalmars.com Resolution| |FIXED -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 07 2011