Skip to content

Intellisense: no error emitted about inaccessible base class member in inline friend function of derived class. #4717

@escape0707

Description

@escape0707

Type: LanguageService

No error emitted about inaccessible base class member in inline friend function of derived class.

Describe the bug

  • OS and Version: Linux x64 5.4.2-arch1-1
  • VS Code Version: 1.40.2
  • C/C++ Extension Version: 0.26.2

To Reproduce

  1. Create and compile a .cpp file which contains the following codes:
class Base {
 protected:
  int prot_mem;
};

class Sneaky : public Base {
  inline friend void clobber(Sneaky &s) { s.j = s.prot_mem = 0; }
  inline friend void clobber(Base &b) { b.prot_mem = 0; }
  int j;
};

Expected behavior

Identify b.prot_mem as error just as if the error appears in a out-of-class friend function definition:

int Base::prot_mem
protected member "Base::prot_mem" (declared at line 3) is not accessible through a "Base" pointer or object

Screenshots

  • Expected:

image

  • Got:

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Language ServiceVisual StudioInherited from Visual StudiobugfixedCheck the Milestone for the release in which the fix is or will be available.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions