Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intellisense not interpreting C++17 auto correctly #2112

Closed
jeffbi opened this issue Jun 10, 2018 · 4 comments
Closed

Intellisense not interpreting C++17 auto correctly #2112

jeffbi opened this issue Jun 10, 2018 · 4 comments
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service parser

Comments

@jeffbi
Copy link

jeffbi commented Jun 10, 2018

Type: LanguageService

  • OS and Version: Linux Mint 64-bit
  • VS Code Version: 1.24.0
  • C/C++ Extension Version: 0.17.4

Intellisense interprets the construct auto p{"Fred"} as deduction of an initializer list. In C++17 that should not be the case.

To Reproduce
Use the following C++17 main.cpp file:

int main()
{
    auto s = "fred";
    auto p{s};
}

along with the following (auto-generated) c_cpp_properties.json file:

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

Red squiggles appear under auto p. Intellisense is seeing this line as a deduction of an initializer list.

Expected behavior
auto p{s} should be recognized as p being a const char *.

@sean-mcmanus
Copy link
Contributor

Thanks for reporting this. It appears to be a bug with our "clang-x64" mode, and doesn't repro with the msvc-x64 mode.

@sean-mcmanus
Copy link
Contributor

This appears fixed in 0.17.7 -- not sure what release actually fixed it. 0.17.8-insiders has more fixes for other scenarios: https://github.com/Microsoft/vscode-cpptools/releases/tag/v0.17.8-insiders , and we made several more parser fixes that haven't been released yet (https://github.com/Microsoft/vscode-cpptools/milestone/14 ).

@sean-mcmanus
Copy link
Contributor

Correction -- it's not fixed in 0.17.7, but it is in 0.17.8-insiders. Also, your compiler library needs to be a new enough version (I tested with gcc-8) or you'll need to #include <initializer_list>.

@bobbrow bobbrow added the fixed Check the Milestone for the release in which the fix is or will be available. label Aug 17, 2018
@bobbrow bobbrow closed this as completed Aug 17, 2018
@jeffbi
Copy link
Author

jeffbi commented Aug 17, 2018

Nice. Thank you.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service parser
Projects
None yet
Development

No branches or pull requests

3 participants