diff --git a/src/libs/cplusplus/LookupContext.cpp b/src/libs/cplusplus/LookupContext.cpp
index 4d3ed932759f5dee2d490a7c33bd38ce71daaf0a..507a5d99aa7439442dd82d4a16815a7234d4a206 100644
--- a/src/libs/cplusplus/LookupContext.cpp
+++ b/src/libs/cplusplus/LookupContext.cpp
@@ -513,8 +513,8 @@ void LookupContext::expandFunction(Function *function,
                                                         q->isGlobal());
         const QList<Symbol *> candidates = resolveClassOrNamespace(nestedNameSpec, visibleScopes);
         for (int j = 0; j < candidates.size(); ++j) {
-            expand(candidates.at(j)->asScopedSymbol()->members(),
-                   visibleScopes, expandedScopes);
+            if (ScopedSymbol *scopedSymbol = candidates.at(j)->asScopedSymbol())
+                expand(scopedSymbol->members(), visibleScopes, expandedScopes);
         }
     }
 }