clear bug?
Jonathan M Davis
jmdavisProg at gmx.com
Mon Sep 5 17:09:01 PDT 2011
On Sunday, September 04, 2011 12:30:58 Dan Olson wrote:
> Using dmd 2.054 on osx:
>
> Calling a instance method after using clear() on an instance is giving
> me a bus error. The instance fields look like they are cleared ok, just
> can't safely call a method. I think this used to work after the object
> was cleared, and was the reason for clear() over the deprecated delete.
Once an object has been cleared, it's invalid. Don't use it. Why would you
ever try and use an object that had been cleared or deleted? The memory for it
has been released!
The reason that delete was deprecated was because it was deemed a bad idea in
a garbage collected language. It has _nothing_ to do with calling functions on
an object after it has been cleared or deleted.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list