microsoft / microsoft/vscode-cpptools

constrained template friend incorrectly flagged as invalid

Open
#11,573 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Language Service more votes needed Visual Studio
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Environment
  • OS and Version: Windows 10 22h2
  • VS Code Version: 1.84.0
  • C/C++ Extension Version: v1.18.0
Bug Summary and Steps to Reproduce

Bug Summary:
image

Steps to reproduce:

  1. Paste this code into a new project
#include<concepts>
#include<vector>
#include<memory>
class BaseNode{
    int value;
    template<std::derived_from<BaseNode> T>
    friend class Database;
    public:
        virtual ~BaseNode(){}
};
template<std::derived_from<BaseNode> T>
class Database{
    std::vector<std::unique_ptr<BaseNode>> nodes;
};
int main(){}
  1. See error

Expected behavior: No error, as compiling with g++ gives no errors.

Configuration and Logs
{
  "configurations": [
    {
      "name": "windows-gcc-x64",
      "includePath": [
        "E:\\",
        "E:\\include"
      ],
      "compilerPath": "D:\\msys64\\mingw64\\bin\\g++.exe",
      "cStandard": "c23",
      "cppStandard": "c++23",
      "intelliSenseMode": "windows-gcc-x64",
      "compilerArgs": [
        "-fno-ms-extensions"
      ]
    }
  ],
  "version": 4
}
Other Extensions

No response

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named. Start by reproducing the diagnostic in the VS Code C/C++ extension with the supplied C++23 example and Windows GCC configuration, then compare IntelliSense with g++; done means the constrained template friend is accepted without an invalid-code error.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, vscode
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.