diff --git a/lib/checkautovariables.cpp b/lib/checkautovariables.cpp index 4c4b9e69135..c7e3b16e5ba 100644 --- a/lib/checkautovariables.cpp +++ b/lib/checkautovariables.cpp @@ -562,7 +562,7 @@ void CheckAutoVariables::checkVarLifetimeScope(const Token * start, const Token errorReturnReference(tok, lt.errorPath, lt.inconclusive); break; } - if (isDeadTemporary(lt.token, nullptr, &mSettings->library)) { + if (isDeadTemporary(lt.token, nullptr, &mSettings->library) && lt.token->variable() && lt.token->variable()->isReference()) { errorReturnTempReference(tok, lt.errorPath, lt.inconclusive); break; }