[Insight-developers] Protected virtual functions made public

Julien Malik julien.malik at c-s.fr
Thu Oct 6 08:21:26 EDT 2011


Hi,

I'm following up with an old thread I started.
I found a good tool to help me with this : ctags 
(http://ctags.sourceforge.net/)

Attached is a script I use to parse the sources and then extract 
potential issues concerning the visibility.

I launched the script on current ITK trunk and you can see attached a 
list of filters which should be studied IMO.
There are some false positives (like PrintSelf in classes not deriving 
from itk::LightObject), but most of what I looked into is reliable info.


If I get confirmation from the community that it should be fixed, I can 
work on a patch.

Cheers,
Julien



Le 15/04/2011 00:54, Luis Ibanez a écrit :
> Hi Julien,
>
> It seems to be a valid C++ construct ...
>
> Although,
> I agree with you in that it is a misleading one,
> and a dangerous one.
>
> It is worth trying to make it back to "protected" in the ImageFileReader,
> and see if there is any valid use for it to be public....
>
>
>      Luis
>
>
>
> -----------------------------------------
> On Mon, Apr 11, 2011 at 10:01 AM, Julien Malik<julien.malik at c-s.fr>  wrote:
>> Hello,
>>
>> I've been seeing a recurrent bug through ITK (initially I saw it inside
>> Orfeo Toolbox) : some filters change the visibility of protected functions
>> of ProcessObject.
>>
>> For example, take the probably most used class of ITK : ImageFileReader.
>> Its GenerateOutputInformation is public, whereas it is protected in
>> ProcessObject.
>> Another candidate is itk::MultiResolutionPyramidImageFilter for example. I'm
>> sure we can find some others.
>> We do have this problem in numerous classes in OTB.
>>
>> As GenerateOutputInformation and UpdateOutputInformation have very similar
>> names, it is very easy for a end-user to be mislead and use the wrong one
>> when it has been made public (by mistake) by the developer.
>>
>> It seems weird to me that gcc does not even warn about this situation
>> (though it is standard C++).
>> A good pointer is :
>> http://stackoverflow.com/questions/2143933/how-to-prevent-derived-class-from-making-a-private-protected-virtual-function-pub
>> It seems like there is nothing to get from gcc (you can compile the code
>> with -Wall -Wextra -Weffc++, and still get no warning)
>>
>> Does someone have a solution for this easy-to-go-wrong case ?
>> Are there other compilers which warn about this (I'm thinking about clang
>> for example) ?
>>
>>
>> Julien
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Kitware offers ITK Training Courses, for more information visit:
>> http://kitware.com/products/protraining.html
>>
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.itk.org/mailman/listinfo/insight-developers
>>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CheckVisibility.sh
Type: application/x-sh
Size: 2152 bytes
Desc: not available
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20111006/35fc5bd8/attachment.sh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: itk_visibility_issue.txt
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20111006/35fc5bd8/attachment.txt>


More information about the Insight-developers mailing list