microsoft / microsoft/vscode-cpptools

Intellisense fails to deduce template arguments for aliases

Open
#8,579 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Bug type: Language Service

Describe the bug

  • OS and Version: Windows 10 Pro 21H2
  • VS Code Version: 1.63.1 (user setup) (fe719cd3e5825bf14e14182fddeb88ee8daf044f)
  • C/C++ Extension Version: 1.7.1: October 19, 2021
  • Other extensions you installed (and if the issue persists after disabling them): many, but only cpptools needed to reproduce
  • Not using ssh remote

Since C++20 (P1814R0) the compiler is supposed to be able to deduce template argruments for template aliases, so following code is legal:

template <typename T>
struct MyTemplate
{
    MyTemplate(T) { }
};

template <typename T>
using MyAlias = MyTemplate<T>;

int main()
{
    auto mt = MyTemplate(0); // intellisense OK
    auto ma = MyAlias(0); // intellisense red squiggles
    return 0;
}

The above code compiles fine using GCC 10.2.0 from mingw, specifically the current winlibs package from chocolatey.

On the line marked as // intellisense red squiggles, intellisense compains about missing arguments for template alias "My Alias" (c/c++(441)) (see (german) screenshot below)

grafik

Steps to reproduce

  1. Put above code in a new c++ project that is configured to use C++20

settings.json:

{
    "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",
    "C_Cpp.default.cppStandard": "c++20"
}

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

Reproduce the report's C++20 example in a new project using the provided settings.json and compare IntelliSense with GCC 10.2.0. Investigate the language-service diagnostic on MyAlias(0); done means template argument deduction for the alias no longer produces missing-arguments red squiggles.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
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.