Vscode-cpptools: Intellisense: no error emitted about inaccessible base class member in inline friend function of derived class.

Created on 8 Dec 2019  路  3Comments  路  Source: microsoft/vscode-cpptools

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

Language Service Visual Studio bug fixed (release pending)

Most helpful comment

All 3 comments

Hi @escape0707 . This also repro's in Visual Studio. (The C/C++ Extension shares common code for IntelliSense with VS). I've opened an issue against VS here.

Fixed in our latest Insiders release: https://github.com/microsoft/vscode-cpptools/releases/tag/0.27.0-insiders.

Thanks for your hardwork on this. But I'm sorry that I can't test it in C++ project for now. Feel free to close this issue if it's confirmed fixed XD!

Was this page helpful?
0 / 5 - 0 ratings