microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.52k stars 1.55k forks source link

Intellisense treats std::vector<float> variable initialization as a function declaration #11109

Open feng000000 opened 1 year ago

feng000000 commented 1 year ago

Environment

Bug Summary and Steps to Reproduce

Bug Summary: Intellisense treats std::vector variable "vec2" as a function declaration. The code can be successfully compiled and run.

Steps to reproduce:

#include <iostream>
#include <vector>

const int width = 5;
const int height = 5;

std::vector<float> vec1(width); // no problem

std::vector<float> vec2(width * height); // Function definition for 'vec2' not found.

int main()
{
    for (auto i : vec1)
        std::cout << i << " ";
    std::cout << std::endl;

    for (auto i : vec2)
        std::cout << i << " ";
    std::cout << std::endl;

    return 0;
}

image

Expected behavior: vec2 is a variable of type std::vector, the length is width * height

Configuration and Logs

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

OUTPUT:
loggingLevel: Debug
loggingLevel has changed to: Debug
LSP: cpptools/textEditorSelectionChange
LSP: cpptools/activeDocumentChange: file:///home/feng/Code/test/test.cpp
LSP: cpptools/getCodeActions: file:///home/feng/Code/test/test.cpp (id: 37)
LSP: cpptools/textEditorSelectionChange
LSP: textDocument/documentHighlight: file:///home/feng/Code/test/test.cpp (id: 38)
LSP: cpptools/getFoldingRanges: file:///home/feng/Code/test/test.cpp (id: 39)
LSP: cpptools/getCodeActions: file:///home/feng/Code/test/test.cpp (id: 40)
LSP: cpptools/textEditorSelectionChange
LSP: cpptools/activeDocumentChange: file:///home/feng/Code/test/test.cpp
LSP: cpptools/getCodeActions: file:///home/feng/Code/test/test.cpp (id: 41)
LSP: cpptools/textEditorSelectionChange
LSP: textDocument/documentHighlight: file:///home/feng/Code/test/test.cpp (id: 42)
LSP: cpptools/getFoldingRanges: file:///home/feng/Code/test/test.cpp (id: 43)
LSP: cpptools/getCodeActions: file:///home/feng/Code/test/test.cpp (id: 44)
LSP: cpptools/textEditorSelectionChange
LSP: cpptools/activeDocumentChange: file:///home/feng/Code/test/test.cpp

Other Extensions

No response

Additional context

image

Colengms commented 1 year ago

Hi @feng000000 . Thanks for reporting this. I've opened an internal bug against VS to track this, as it occurs in code shared with VS. (1839471).

Note that the 3-dots is not coming from IntelliSense per se. It's part of the CDD (Create Declaration/Definition) feature, which is incorrectly considering it a candidate.