Hi,
I'd like to hear some opinions. Usually I only use Linux and the gcc. And I always make sure that it compiles cleanly. So does the code below. Now I wanted to try to compile my program with Visual Studio 2005. The compiler gave me the following warning:
'ImageScaler::scaleFactor' : not all control paths return a value
In principle the compiler is right, but I wonder if this counts as bad design. The control path Visual Studio complained about can never be executed. Of course, when I compile as release, the assertion will go away and this might open the undefined path.
I just wonder why this piece of code is ok for the gcc.
double ImageScaler::scaleFactor(RubberBands::lineType type) const{
switch(type){
case RubberBands::horizontal:
return _scaleFactorX;
case RubberBands::vertical:
return _scaleFactorY;
default:
assert(false);
}
}
double ImageScaler::scaleFactor(RubberBands::lineType type) const{
switch(type){
case RubberBands::horizontal:
return _scaleFactorX;
case RubberBands::vertical:
return _scaleFactorY;
default:
assert(false);
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks