Skip to content

C++17 class template argument deduction not working correctly  #2907

@aryan-gupta

Description

@aryan-gupta

Type: LanguageService

  • OS and Version: Arch Linux with Gnome 3
  • VS Code Version: 1.29.1
  • C/C++ Extension Version: 0.20.1

I am having an issue where vscode is telling me I have an compile error when it compiles correctly with gcc and clang. Here is an c++ example that triggers the issue:

struct A {};

template<typename T>
struct B : public A {
	B(int p1, T p2) {  }
};

int main()
{
	A* test1 = new B{ 5, 5.0 }; // < Error

	double dtest = 5.0;
	A* test2 = new B{ 5, dtest }; // < Error

	B<double>* test3 = new B{ 5, 5.0 }; // < Error

	A* test4 = new B<double>{ 5, 5.0 }; // < Works Correctly
}

Intellisense is saying there is an error: too many initializer values. However the code compiles correctly with gcc 8.2 and clang 7.

screenshot from 2018-12-08 22-14-01

My c_cpp_properties.json is as follows:

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cppStandard": "c++17",
            "intelliSenseMode": "gcc-x64"
        }
    ],
    "version": 4
}

Does not resolve issue when using clang-x64.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Language ServicebugfixedCheck the Milestone for the release in which the fix is or will be available.parser

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions