Skip to content

false positive problem 'override' does not override when using elaborated type specifier #13729

@markusobi

Description

@markusobi

Environment

  • OS and Version: Windows 10 Version 22H2 (OS Build 19045.5965)
  • VS Code Version: 1.101.2 (system setup)
  • C/C++ Extension Version: 1.26.3

Bug Summary and Steps to Reproduce

Bug Summary:
IntelliSense complains with member function declared with 'override' does not override a base class member in some weird corner case when using elaborated type specifier (that introduces a declaration) + inheritance + namespace.

Steps to reproduce:

Create a C++ file with the following content:

struct Base
{
    using Alias = struct IncompleteType;
    virtual void foo(IncompleteType*) = 0;
};

struct Derived : Base
{
    void foo(IncompleteType*) override {}
};

namespace my_namespace
{
    Derived derived;
}

IntelliSense reports:
member function declared with 'override' does not override a base class member
That code however seems to be legal C++.

Problem also happens when removing the Alias line and using virtual void foo(struct IncompleteType*) = 0; instead. Then you will additionally get a object of abstract class type "Derived" is not allowed: problem.
Since the abstract class is just a subsequent error, I crafted the example to be closer to the root cause.

Be careful when editing the file. IntelliSense becomes inconsistent. You might need to reopen vscode to see the error again after a code change. So crank up your paranoia level or else you'll miss some heisenbugs.

Weird changes that make the problem go away:

  • put the structs into a namespace or
  • don't put the Derived usage in a namespace or
  • remove Derived derived; or
  • add Derived derived2; above the namespace

Expected behavior:
IntelliSense does not report errors.

Configuration and Logs

Happens with and without c_cpp_properties.json.

-------- Diagnostics - 6/25/2025, 11:44:45 PM
Version: 1.26.3
Current Configuration:
{
    "name": "Win32",
    "includePath": [
        "${workspaceFolder}/**"
    ],
    "defines": [
        "_DEBUG",
        "UNICODE",
        "_UNICODE"
    ],
    "windowsSdkVersion": "10.0.22621.0",
    "compilerPath": "cl.exe",
    "cStandard": "c17",
    "cppStandard": "c++17",
    "intelliSenseMode": "windows-msvc-x64",
    "compilerPathInCppPropertiesJson": "cl.exe",
    "intelliSenseModeIsExplicit": false,
    "cStandardIsExplicit": false,
    "cppStandardIsExplicit": false,
    "mergeConfigurations": false,
    "recursiveIncludes": {},
    "recursiveIncludesReduceIsExplicit": false,
    "recursiveIncludesPriorityIsExplicit": false,
    "recursiveIncludesOrderIsExplicit": false,
    "compilerPathIsExplicit": false,
    "browse": {
        "limitSymbolsToIncludedHeaders": true
    }
}
Additional Tracked Settings:
{
    "editorTabSize": 4,
    "editorInsertSpaces": true,
    "editorAutoClosingBrackets": "languageDefined",
    "filesEncoding": "utf8",
    "filesAssociations": {},
    "filesExclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/.DS_Store": true,
        "**/Thumbs.db": true
    },
    "filesAutoSaveAfterDelay": false,
    "editorInlayHintsEnabled": true,
    "editorParameterHintsEnabled": true,
    "searchExclude": {
        "**/node_modules": true,
        "**/bower_components": true,
        "**/*.code-search": true
    },
    "workbenchSettingsEditor": "ui"
}
cpptools version (native): 1.26.3.0
Current database path: C:\USERS\*censored*\APPDATA\LOCAL\TEMP\{E2C1A331-3112-4CC4-8F2C-5F7D789AC96C}\.BROWSE.VC.DB
Translation Unit Mappings:
[ C:\Users\*censored*\Downloads\elaborated_type_specifier_bug.cpp - source TU]:
Translation Unit Configurations:
[ C:\Users\*censored*\Downloads\elaborated_type_specifier_bug.cpp ]
    Process ID: 17280
    Memory Usage: 52 MB
    Compiler Path: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\bin\Hostx64\x64\cl.exe
    Include paths:
        system include: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\include
        system include: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\atlmfc\include
        system include: C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um
        system include: C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt
        system include: C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared
        system include: C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\winrt
        system include: C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\cppwinrt
    Defines:
        _DEBUG
        UNICODE
        _UNICODE
    Standard Version: ms_c++17
    IntelliSense Mode: windows-msvc-x64
Total Memory Usage: 52 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 5033

Other Extensions

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions