[Insight-developers] Protected virtual functions made public
Julien Malik
julien.malik at c-s.fr
Mon Apr 11 10:01:36 EDT 2011
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
More information about the Insight-developers
mailing list