c++ - : 0xC0000005: Access violation reading location 0xccccccc0 with recursive vector search 中 0x770115de 的未处理异常

标签 c++ string visual-studio-2008 recursion

daedalus_1.4.exe 中 0x770115de 的未处理异常:0xC0000005:读取位置 0xccccccc0 的访问冲突。

string temp;
string locName = "0";

vector<vector<string>> l;
int m = 100, n = 3; //vector dimension
l.resize(m);
for(int i = 0; i < m; ++i) l[i].resize(n);

temp.clear();

if(line.substr(1, 17) == "Timing LocationID" && arrayFull == true) {
    int i = 0; //starting char
    while (line[i++] != '='); //increment to next
    while (line[++i] != '"') temp += line[i];
    locName = findLocation(temp, 0, "", l);

string findLocation (string temp, int index, string locName, vector<vector<string>> &l)
{
    if (temp == "*") return locName; // <------errors here on return
    if (l[index][0] == temp) findLocation(l[index][1], 0, locName.insert(0,l[index][2]), l);
    else findLocation(temp, ++index, locName, l);
}

此函数循环遍历 2xvector 并返回由父->子 vector 单元组成的串联字符串

这些来自调用栈;看起来像字符串析构函数

__CLR_OR_THIS_CALL ~basic_string()
    {   // destroy the string
    _Tidy(true);
    }

void __CLR_OR_THIS_CALL _Tidy(bool _Built = false,
    size_type _Newsize = 0)
    {   // initialize buffer, deallocating any storage
    if (!_Built)
        ;
    else if (_BUF_SIZE <= _Myres)
        {   // copy any leftovers to small buffer and deallocate
        _Elem *_Ptr = _Bx._Ptr;
        if (0 < _Newsize)
            _Traits_helper::copy_s<_Traits>(_Bx._Buf, _BUF_SIZE, _Ptr, _Newsize);
        _Mybase::_Alval.deallocate(_Ptr, _Myres + 1);
        }
    _Myres = _BUF_SIZE - 1;
    _Eos(_Newsize);
    }

最佳答案

你的函数字符串findLocation()

并非在所有路径上都返回值,也许您的意思是:

string findLocation (string temp, int index, string locName, vector<vector<string>> &l)
{
    if (temp == "*") return locName;
    if (l[index][0] == temp) return findLocation(l[index][1], 0, locName.insert(0,l[index][2]), l);
    else return findLocation(temp, ++index, locName, l);
}

关于c++ - : 0xC0000005: Access violation reading location 0xccccccc0 with recursive vector search 中 0x770115de 的未处理异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11461892/

相关文章:

c++ - 如何从模板类创建具体类

regex - 使用 sed 在字符串中附加字符串值

java - 想要借助正则表达式替换标签中的值属性吗?

visual-studio-2008 - Visual Studio 缺少 "Open in blend"选项

c# - 如何在构造函数中查找参数数量

C++11 "overloaded lambda"带有可变参数模板和变量捕获

c++ - 指定函数参数类型,但不是变量

c++ - 与删除器共享指针

python - 提取嵌入在python中的字符串中的多个列表

c# - System.IO.FileNotFoundException 未处理消息 =“The specified module could not be found. (Exception from HRESULT: 0x8007007E)”