Reputation: 10936
These six methods (really three, the ones that actually throw the warning are the non-const versions) are causing a C4717 (functions recursive on all paths) warning yet the method following these do not (exactly the same that I can tell...). What am I missing that is causing the warning for these but not the other one?
Warning-generating methods:
template<class T>
const QuadTreeNode<T>* QuadTree<T>::GetRoot() const {
return _root;
}
template<class T>
QuadTreeNode<T>* QuadTree<T>::GetRoot() {
return static_cast<const QuadTree<T> >(*this).GetRoot();
}
template<class T>
const int QuadTree<T>::GetNumLevels() const {
return _levels;
}
template<class T>
int QuadTree<T>::GetNumLevels() {
return static_cast<const QuadTree<T> >(*this).GetNumLevels();
}
template<class T>
const bool QuadTree<T>::IsEmpty() const {
return _root == NULL;
}
template<class T>
bool QuadTree<T>::IsEmpty() {
return static_cast<const QuadTree<T> >(*this).IsEmpty();
}
Non-Warning-generating method:
template<class T>
const Rectangle QuadTreeNode<T>::GetNodeDimensions() const {
return _node_bounds;
}
template<class T>
Rectangle QuadTreeNode<T>::GetNodeDimensions() {
return static_cast<const QuadTreeNode<T> >(*this).GetNodeDimensions();
}
Upvotes: 3
Views: 1671
Reputation: 3276
As mentioned by ildjarn, the is an acknowledged bug with the warning. If you look at the code at the most basic usage similar of your code, there is no warning with the following (and is not recursive).
class A
{
public:
bool IsEmpty()
{
return static_cast<const A>(*this).IsEmpty();
}
bool IsEmpty() const
{
return true;
}
};
int main()
{
A whatever;
whatever.IsEmpty();
return 0;
}
Upvotes: 1