[Insight-developers] Protected virtual functions made public

Luis Ibanez luis.ibanez at kitware.com
Thu Apr 14 18:54:18 EDT 2011


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
>


More information about the Insight-developers mailing list