0

以下で強調表示されている行で valgrind がエラー (条件付きのジャンプまたは移動は初期化されていない値に依存する) を返すため、C++ コードに問題があります。「 type 」を空の文字列で初期化しようとしましたが、うまくいかないようです。ここで何か助けていただければ幸いです。

よろしくお願いします。

ナンダネーター

int AB_CD::checkType(string & str)
{
    int tmp = 0;

    string type;


    while (getNextSubstring(str, type))
    {
        if (type == "AAA")     <<<<< ----- Valgrind error pointing here 
        {
            tmp |= static_cast<int>(TYPE_AAA);
        }
        else if (type == "BBB") <<<<< ----- Valgrind error pointing here 
        {
            tmp |= static_cast<int>(TYPE_BBB);
        }
        else if (type == "CCC") <<<<< ----- Valgrind error pointing here 
        {
            tmp |= static_cast<int>(TYPE_CCC);
        }
        else
    {
        //Print a warning
    }

    }

    return tmp;

}



bool AB_CD::getNextSubstring(string & input, string & substring)
{
    bool found_substring = false;

    string::size_type start = input.find_first_not_of(" ,");
    string::size_type end = input.find_first_of(" ,", start);

    if (start != string::npos)
    {
        substring = input.substr(start, end-start);
        input.erase(start, end-start);
        found_substring = true;
    }
    return found_substring;
}
4

0 に答える 0