Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
trigger-segfault opened this issue Jan 29, 2025 · 0 comments
Open
Labels
bug Feature: Auto-complete Language Service Works in VS So we'd need to fix it for VS Code to reach parity.

Comments

@trigger-segfault
Copy link

trigger-segfault commented Jan 29, 2025

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

@sean-mcmanus sean-mcmanus added the Works in VS So we'd need to fix it for VS Code to reach parity. label Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Feature: Auto-complete Language Service Works in VS So we'd need to fix it for VS Code to reach parity.
Projects
Status: No status
Development

No branches or pull requests

2 participants