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

Andi Clemens andi.clemens at gmx.net
Wed Jun 15 13:10:39 BST 2011


Right, we are still using too many raw pointers.
Qt, C++ stdlib and boost have many things to handle pointers automatically.

See Item #13 in "Effective C++": Use objects to manage resources
A great book, everyone should read it...

Anyway sure auto_ptr and friends will "slow" down execution, but with all  
the checks we do anyway, I guess it will not be noticeable.
It is still much faster than garbage collection...

Andi


On Wed, 15 Jun 2011 11:55:50 +0200, Marcel Wiesweg <marcel.wiesweg at gmx.de>  
wrote:

>
>> 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


-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/



More information about the Digikam-devel mailing list