Skip to content

IntelliSense false error constructing std::span<const T> from std::vector<T> #14504

@seangelos

Description

@seangelos

Environment

  • OS and Version: Fedora Linux 44
  • VS Code Version: 1.123.0
  • C/C++ Extension Version: 1.32.2

Bug Summary and Steps to Reproduce

Bug Summary: IntelliSense falsely reports an error when attempting to create an std::span<const T> from std::vector<T>. Code compiles without issue by GCC and Clang.

Steps to reproduce:

  1. Create a file with the following sample code:
#include <print>
#include <span>
#include <vector>

int main()
{
	std::vector<int> v = { 1, 2, 3 };
	std::span<const int> s(v);
	std::println("{}", s);
}
  1. Set C++ properties accordingly (C++23 mode)
  2. The following error is reported:
no instance of constructor "std::span<_Type, _Extent>::span [with _Type=const int, _Extent=18446744073709551615UL]" matches the argument list
argument types are: (std::vector<int, std::allocator<int>>)

Expected behavior: No error should be reported.

Workaround: This error is not reported if intelliSenseMode is set to linux-clang-x64 with compilerArgs -stdlib=libc++. Perhaps linked to #14464? With the above sample, a different false error about std::println is reported, but that is probably a separate issue.

Configuration and Logs

C/C++ Logs:

Version: 1.32.2
Current Configuration:
{
    "name": "Linux",
    "includePath": [
        "/home/.../test/**"
    ],
    "defines": [],
    "compilerPath": "/usr/bin/g++",
    "cStandard": "c23",
    "cppStandard": "c++23",
    "intelliSenseMode": "linux-gcc-x64",
    "compilerPathIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "intelliSenseModeIsExplicit": true,
    "recursiveIncludesReduceIsExplicit": false,
    "recursiveIncludesPriorityIsExplicit": false,
    "recursiveIncludesOrderIsExplicit": false,
    "compilerPathInCppPropertiesJson": "/usr/bin/g++",
    "mergeConfigurations": false,
    "recursiveIncludes": {},
    "browse": {
        "limitSymbolsToIncludedHeaders": true
    }
}
Modified Settings:
{
    "C_Cpp.intelliSenseCacheSize": 0
}
Additional Tracked Settings:
{
    "editorTabSize": 4,
    "editorInsertSpaces": true,
    "editorAutoClosingBrackets": "languageDefined",
    "filesEncoding": "utf8",
    "filesAssociations": {},
    "filesExclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/.DS_Store": true,
        "**/Thumbs.db": true
    },
    "filesAutoSaveAfterDelay": false,
    "editorInlayHintsEnabled": true,
    "editorParameterHintsEnabled": true,
    "searchExclude": {
        "**/node_modules": true,
        "**/bower_components": true,
        "**/*.code-search": true
    },
    "workbenchSettingsEditor": "ui"
}
cpptools version (native): 1.32.2.0
Current database path: /home/.../.cache/vscode-cpptools/a55973f238bd7abb0c0547bc93188a1a/.browse.VC.db
No active translation units.

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 32372

Other Extensions

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No fields configured for Bug.

    Projects

    Status
    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions