[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Patch - wrong casts, no cleanup in destructor

From: Stefan Küng <tortoisesvn_at_gmail.com>
Date: Fri, 04 Feb 2011 20:04:51 +0100

On 04.02.2011 07:37, Dmitry wrote:
> Hey.
>
>
> 03.02.2011, 22:18, "Stefan Küng"<tortoisesvn_at_gmail.com>:
>>> - C-style casts where static_casts would be safer (compiler will
>>> show an error if a cast is not possible in case of static_cast,
>>> but not in case of C-style cast)
>> static_cast doesn't work here because ppv is a void pointer.
>
> LOL, this one is very ironic. Yes, static_cast won't work in this
> very case, but not because "ppv" is of type "void**". "*ppv" is of
> type "void*", so any object pointer can be copied there even without
> an explicit cast.
>
> The real reason why static_cast won't work here is because class
> CShellExt inside TortoiseOverlays only inherits from
> IShellIconOverlayIdentifier and so it doesn't implement most of the
> interfaces listed in the if-else comparison chain. In some branches
> of the if-else comparison C-style cast will work as reinterpret_cast
> (as in "shut up, stupid compiler, I demand you extinguish fire with
> kerosene") and the caller will be given a non-null pointer to an
> object that doesn't implement the requested interface.
>
> That code is copied from CShellExt in TortoiseShell, where the class
> is indeed inherited from all those interfaces. static_cast works
> there - I copied that code into a separate project to test. If
> static_cast was used initially the compiler would prevent such
> unfortunate use of copy-paste.

Ups. You're absolutely right.
Fixed in r20823.

Stefan

-- 
        ___
   oo  // \\      "De Chelonian Mobile"
  (_,\/ \_/ \     TortoiseSVN
    \ \_/_\_/>    The coolest Interface to (Sub)Version Control
    /_/   \_\     http://tortoisesvn.net
------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=757&dsMessageId=2702308
To unsubscribe from this discussion, e-mail: [dev-unsubscribe_at_tortoisesvn.tigris.org].
Received on 2011-02-04 20:05:05 CET

This is an archived mail posted to the TortoiseSVN Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.