delete and references?

Leandro Lucarella llucax at gmail.com
Sat Aug 8 07:22:40 PDT 2009


Andrei Alexandrescu, el  8 de agosto a las 08:42 me escribiste:
> Jarrett Billingsley wrote:
> >On Sat, Aug 8, 2009 at 9:17 AM, Andrei
> >Alexandrescu<SeeWebsiteForEmail at erdani.org> wrote:
> >>FWIW, I am trying to convince Walter to not reclaim memory in delete, but
> >>instead only call destructors. D continues C++'s mistake of conflating
> >>lifetime termination with memory reclamation.
> >Why?  Instead of dangling pointers, you'd end up with pointers to
> >finalized objects, which would probably lead to harder-to-catch bugs
> >(since then you wouldn't even get a segfault).
> 
> Getting a segfault == lucky

You could easily get a segfault *if* the memory is big enough (> 1 page)
*and* if there is some support from the OS. Remove the RW permissions from
the page and when somebody wants to access it or write it... BOOM! You'll
get your segfault.

So it's not only lucky, so can choose your own destiny ;)

-- 
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
----------------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------------
CAMPAÑA POR LA PAZ: APLASTARON JUGUETES BÉLICOS
	-- Crónica TV



More information about the Digitalmars-d mailing list