[cfe-commits] r165363 - /cfe/trunk/www/analyzer/potential_checkers.html

Dmitri Gribenko gribozavr at gmail.com
Sat Oct 6 10:26:31 PDT 2012


On Sat, Oct 6, 2012 at 8:16 PM, David Blaikie <dblaikie at gmail.com> wrote:
> On Sat, Oct 6, 2012 at 9:59 AM, Dmitri Gribenko <gribozavr at gmail.com> wrote:
>> -<tr><td><span class="name">smartptr.AutoPtrInit<br>
>> -(C++03)</span><br><br>
>> -auto_ptr should store a pointer to an object obtained via new as allocated
>> -memory will be cleaned using delete
>> +<tr><td><span class="name">smartptr.SmartPtrInit<br>
>> +(C++)</span><br><br>
>> +C++03: auto_ptr should store a pointer to an object obtained via new as allocated
>> +memory will be cleaned using delete<br>
>> +C++11: unique_ptr and shared_ptr allow
>> +to specify a custom deleter to handle the new[]/delete[] case correctly
>
> unique_ptr actually doesn't need extra work from the user - if you use
> unique_ptr<T[]> instead of unique_ptr<T>, that is.
>
> shared_ptr isn't ideal for holding arrays (doesn't provide operator[]
> for one thing) but, yes, with a custom deleter it can at least do so
> correctly
>
> (& of course with custom deleters both of these can handle completely
> unrelated resource allocation/deallocation strategies)

Thank you!  Corrected in r165365.

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/



More information about the cfe-commits mailing list