diff --git a/src/shared/cplusplus/Scope.cpp b/src/shared/cplusplus/Scope.cpp
index bdca9f8536d9175386be846db68ecbda43fbe6d7..db05d1bdc93774c2c3465378115adfc8aeeb9457 100644
--- a/src/shared/cplusplus/Scope.cpp
+++ b/src/shared/cplusplus/Scope.cpp
@@ -206,7 +206,9 @@ Symbol *Scope::lookat(Identifier *id) const
     Symbol *symbol = _hash[h];
     for (; symbol; symbol = symbol->_next) {
         Name *identity = symbol->identity();
-        if (NameId *nameId = identity->asNameId()) {
+        if (! identity) {
+            continue;
+        } else if (NameId *nameId = identity->asNameId()) {
             if (nameId->identifier()->isEqualTo(id))
                 break;
         } else if (TemplateNameId *t = identity->asTemplateNameId()) {