Skip to content

Using auto with direct initialization, reports problems. #2299

@omicronns

Description

@omicronns

Type: LanguageService

Using auto and brace initialization in one statement, causes extension to report following problems with code, even though it compiles fine.

{
	"resource": "vscode-intelisense/main.cxx",
	"owner": "_generated_diagnostic_collection_name_#0",
	"code": "undefined",
	"severity": 8,
	"message": "cannot deduce 'auto' type",
	"startLineNumber": 4,
	"startColumn": 5,
	"endLineNumber": 4,
	"endColumn": 5
}
{
	"resource": "vscode-intelisense/main.cxx",
	"owner": "_generated_diagnostic_collection_name_#0",
	"code": "undefined",
	"severity": 8,
	"message": "an #include <initializer_list> is needed prior to a use of std::initializer_list, including an implicit use",
	"startLineNumber": 4,
	"startColumn": 12,
	"endLineNumber": 4,
	"endColumn": 12
}
  • OS and Version: Linux 4.17.6-1-ARCH
  • VS Code Version: 1.24.1 and 1.25.1
  • C/C++ Extension Version: 0.17.7
  • Clang Version: 6.0.1

To Reproduce

Example:
c_cpp_properties.json

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

main.cxx

int main() {
    int x {1};  // ok
    auto y = 2; // ok
    auto z {3}; // vscode shows problems, compiles fine

    return 0;
}

Steps to reproduce the behavior:

  1. Recreate file structure:
vscode-intelisense
  |
  |-main.cxx
  .vscode
    |-c_cpp_properties.json
  1. Open vscode-intelisense directory in vscode.
  2. Problems should be visible.

Expected behavior

No problems reported.

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions