diff --git a/src/libs/cplusplus/ExpressionUnderCursor.cpp b/src/libs/cplusplus/ExpressionUnderCursor.cpp index d8c7fc55fbf714bfc88704d162a6bb2babd512a7..08c723dc0c2b9d557be82545ef0162208926c24e 100644 --- a/src/libs/cplusplus/ExpressionUnderCursor.cpp +++ b/src/libs/cplusplus/ExpressionUnderCursor.cpp @@ -147,11 +147,13 @@ int ExpressionUnderCursor::startOfExpression_helper(BackwardsScanner &tk, int in --i; } - int j = i; - while (tk[j].is(T_LBRACKET)) - ++j; - if (tk[j].is(T_IDENTIFIER) && tk[j + 1].is(T_IDENTIFIER)) - return i; + if (i >= 0) { + int j = i; + while (tk[j].is(T_LBRACKET)) + ++j; + if (tk[j].is(T_IDENTIFIER) && tk[j + 1].is(T_IDENTIFIER)) + return i; + } } return index - 1; } else if (tk[index - 1].is(T_RPAREN)) {