diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 9ffaa6940..f5e4617dc 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3133,11 +3133,12 @@ bool Tokenizer::simplifySizeof() // sizeof( a ) else if (Token::Match(tok->next(), "( %var% )")) { - if (sizeOfVar.find(tok->tokAt(2)->varId()) != sizeOfVar.end()) { + std::map::const_iterator sizeOfVarPos = sizeOfVar.find(tok->tokAt(2)->varId()); + if (sizeOfVarPos != sizeOfVar.end()) { tok->deleteNext(); tok->deleteThis(); tok->deleteNext(); - tok->str(MathLib::toString(sizeOfVar[tok->varId()])); + tok->str(MathLib::toString(sizeOfVarPos->second)); ret = true; } else { // don't try to replace size of variable if variable has