Skip to content

Public members of private base class show in autocomplete list #13215

@trigger-segfault

Description

@trigger-segfault

Environment

  • OS and Version: Windows 10 Pro, 22H2, 19045.5371
  • VS Code Version: 1.96.4 (user setup)
  • C/C++ Extension Version: 1.23.5
  • If using SSH remote, specify OS of remote machine: No SSH

Bug Summary and Steps to Reproduce

Bug Summary:
When the autocomplete list for members of a class shows while typing, public members (fields, methods, enums, etc.) from private base classes will show in the list as if the the base class was public, despite them being inaccessible outside of the derived class.

Steps to reproduce:

  1. Create a standalone .cpp file without any extension or workplace-specific settings.
  2. Create a class that privately inherits from a base class.
  3. In a function (not a method of the derived class) with a local variable of this derived class, open the autocomplete list by typing . after the name.
  4. Public members of base class will show in the list, even though it is private.
class A {
public:
    int value;
};

class B : private A {};

void foo() {
    B b;
    // Typing here: `value` member is visible in list that pops up.
    b.
}

Image

Expected behavior:
Public members of a private base class should not appear in the autocomplete list in a scope where they can't be used, just like how is done with normal private/protected members.

Configuration and Logs

"C_Cpp.autoAddFileAssociations": false,

Other Extensions

Issue persists after disabling all other extensions and reloading window.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions