Thread overview | ||||||
---|---|---|---|---|---|---|
|
September 18, 2013 [Issue 11060] New: delete gives InvalidMemoryOperationError | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=11060 Summary: delete gives InvalidMemoryOperationError Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: major Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: thelastmammoth@gmail.com --- Comment #0 from thelastmammoth@gmail.com 2013-09-17 22:13:43 PDT --- class B{ int*a; this(){ a=new int; } ~this(){ version(A1) delete a;//core.exception.InvalidMemoryOperationError ; even though http://dlang.org/deprecate.html#delete doesn't list as deprecated yet version(A2) a.clear;//works even though docs recommends DEPRECATED 'Scheduled for deprecation in December 2012. Please use destroy instead of clear.'; and should appear in http://dlang.org/deprecate.html#delete version(A3) a.destroy;//OK } } void main(){ auto a=new B; } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
September 18, 2013 [Issue 11060] delete gives InvalidMemoryOperationError | ||||
---|---|---|---|---|
| ||||
Posted in reply to thelastmammoth@gmail.com | http://d.puremagic.com/issues/show_bug.cgi?id=11060 Maxim Fomin <maxim@maxim-fomin.ru> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |maxim@maxim-fomin.ru Resolution| |INVALID --- Comment #1 from Maxim Fomin <maxim@maxim-fomin.ru> 2013-09-17 22:56:17 PDT --- Please read the spec. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
September 18, 2013 [Issue 11060] delete gives InvalidMemoryOperationError | ||||
---|---|---|---|---|
| ||||
Posted in reply to thelastmammoth@gmail.com | http://d.puremagic.com/issues/show_bug.cgi?id=11060 --- Comment #2 from thelastmammoth@gmail.com 2013-09-17 23:13:03 PDT --- (In reply to comment #1) > Please read the spec. It would be helpful if you could be more specific. * as I wrote in the bug report, why is 'clear' not deprecated even though spec says it should be by december 2012? (and it's also in several phobos modules) * according to http://dlang.org/memory.html, 'If there is a delete(), there should be a corresponding new()' In my example, there is no new() function, so why does it even compile? * according to Jonathan Davis (see email "allocate array with new"): "No. _Never_ use delete. It's going to be deprecated". * in http://dlang.org/deprecate.html#delete, it says delete will be deprecated at a later time. * a number of phobos modules use delete. So all in all the spec is not very clear to me, and maybe to others as well. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
September 18, 2013 [Issue 11060] delete gives InvalidMemoryOperationError | ||||
---|---|---|---|---|
| ||||
Posted in reply to thelastmammoth@gmail.com | http://d.puremagic.com/issues/show_bug.cgi?id=11060 --- Comment #3 from Maxim Fomin <maxim@maxim-fomin.ru> 2013-09-17 23:22:09 PDT --- This was discussed really plenty of times - current garbage collector is not reenterable. So, if GC during garbage collection calls destructor, you cannot invoke any operation which directly or indirectly calls the GC. Clear() and destroy() work because they don't call the GC. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation