无限递归C++

Moh*_*him 1 c++ recursion

我正在写这个代码,一个函数递归调用自己.但是我陷入了一个无限循环,因为它似乎在函数返回时它没有返回到while循环的结束括号但它返回到int o定义的地方..任何想法问题可能在哪里?

ErrorCode QuadTree::PartialSearchHelper(Key *key, const uint64_t QInternal, Iterator ** records,int l[], int pow) {
    try {
        uint64_t temp=(&indexVec[QInternal])->Firstchild;
        uint64_t ch = (&indexVec[QInternal])->Firstchild;
        for (int i = 0; i < pow; i++) {
            while (!(&indexVec[temp + l[i]])->isLeaf) {
                int o= l[i]; //it returns here after finishing recursion call!!!!!!!!!
                PartialSearchHelper(key, temp + l[i], records, l, pow);
            }                        
            ((&indexVec[temp + l[i]]))->findPartial(key, records);
        }

    } catch (std::bad_alloc &e) {
        throw (kErrorOutOfMemory);
    } catch (ErrorCode &e) {
        throw (e);
    } catch (...) {
        throw (kErrorGenericFailure);
    }
    return kOk;
}
Run Code Online (Sandbox Code Playgroud)

小智 8

你没有在while内部改变任何值,所以它只是在较低级别的调用中重新启动while