digitalmars.D.bugs - [Issue 12252] New: struct default constructors that execute code.
- d-bugmail puremagic.com (34/34) Feb 25 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12252
- d-bugmail puremagic.com (12/12) Feb 25 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12252
- d-bugmail puremagic.com (12/12) Feb 28 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12252
- d-bugmail puremagic.com (19/19) Feb 28 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12252
https://d.puremagic.com/issues/show_bug.cgi?id=12252 Summary: struct default constructors that execute code. Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: remotion4d gmail.com extern(C) int w_init(CWrapper *p); extern(C) void w_free(CWrapper *p); struct CWrapper { this() { //not possible w_init(&this); } ~this() { w_free(&this); } } void main(){ S s; //should call w_init() S s1 = S(); //should call w_init() too } While porting C++ code to D2 it is some times necessary to do be able to mimic C++ class/struct behavior. Using this(int dummy){ ... } as a workaround compiles but does not work. Other workarounds are complicated and error phone. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 25 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12252 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs eml.cc Severity|normal |enhancement Converted to enhancement, because D is working as designed here (and from past discussions I have seen, this is at best a controversial change). -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 25 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12252 yebblies <yebblies gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |yebblies gmail.com Resolution| |DUPLICATE *** This issue has been marked as a duplicate of issue 3852 *** -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 28 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12252 Ok then why any other workarounds for this problem do not work too ? Here is one possible workaround that does not work. struct S { disable this(); disable this(this); this(int i){ } static S opCall(){ S s = S(123); return s; } } This would help to find places in ported C++ code that need to be changed but it does not compiles. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 28 2014