Thread overview | ||||||
---|---|---|---|---|---|---|
|
February 25, 2014 [Issue 12252] New: struct default constructors that execute code. | ||||
---|---|---|---|---|
| ||||
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 --- Comment #0 from Remo <remotion4d@gmail.com> 2014-02-25 06:56:36 PST --- 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: ------- |
February 25, 2014 [Issue 12252] struct default constructors that execute code. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Remo | 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 --- Comment #1 from bearophile_hugs@eml.cc 2014-02-25 07:03:23 PST --- 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: ------- |
February 28, 2014 [Issue 12252] struct default constructors that execute code. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Remo | 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 --- Comment #2 from yebblies <yebblies@gmail.com> 2014-02-28 23:51:14 EST --- *** 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: ------- |
February 28, 2014 [Issue 12252] struct default constructors that execute code. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Remo | https://d.puremagic.com/issues/show_bug.cgi?id=12252 --- Comment #3 from Remo <remotion4d@gmail.com> 2014-02-28 05:07:29 PST --- 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: ------- |
Copyright © 1999-2021 by the D Language Foundation