究竟是什么警告C4718(Visual Studio)?

Mar*_*Mao 4 c++ recursion compiler-warnings visual-studio-2012

msdn链接

在这打字:

'function call':递归调用没有副作用,删除

A函数包含递归调用,否则没有副作用.正在删除对此功能的调用.程序的正确性不受影响,但行为是.离开调用可能会导致运行时堆栈溢出异常,而删除调用会消除这种可能性.

导致此警告的代码是:

template<class Key, class Value>
void Map<Key, Value>::Clear(NodeType* pNode)
{
    ((Key*) (pNode->m_key))->~Key();
    ((Value*) (pNode->m_item))->~Value();

    NodeType* pL = pNode->GetLeftChild();
    NodeType* pR = pNode->GetRightChild();
    if (pL != &m_dummy)
    {
        Clear(pL);
    }
    if (pR != &m_dummy)
    {
        Clear(pR);
    }
}
Run Code Online (Sandbox Code Playgroud)

还有1点:这个警告只发生在发布版本中(/ Ox)

这警告是什么?谢谢!

MSa*_*ers 6

我敢打赌它发生在什么时候~Key~Value没有操作.编译器会注意到这个函数没有其他功能,所以它完全消除了这个功能.