[Digikam-devel] Re: delete does not reset the pointer in GCC (4.6.0)

Marcel Wiesweg marcel.wiesweg at gmx.de
Wed Jun 15 10:55:50 BST 2011


> a few months ago, maybe 2 years.
> I know that I always added
> xyz = 0;
> to my code before, but then it was removed again because it is not  
> neccessary with modern compilers (I don't know who said that).

When googling and reading through the usual sources (stackoverflow etc.) I see noone saying that any compiler sets a pointer to 0, I would even guess delete should _not_ change the value of the passed pointer unless the C++ standard says so.
There are the usual stories not to use raw pointers and use concepts to make sure you are always sure never to use deleted pointers again, but in the end, if you are playing with raw pointers (which we are doing still in too many areas IMO, but getting less) and need to delete and reuse the variable, be sure to set it to 0.

Marcel
-- 
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de



More information about the Digikam-devel mailing list