Errors if I use char[] string inisialisation using std::filesystem::path
Environment
- OS and Version: Windows 11 22H2
- VS Code Version: 1.81.1
- C/C++ Extension Version: 1.17.5
I use Clang 16.0.5 under MSYS2 enviroment (Clang profile (UCRT runtime))
Bug Summary and Steps to Reproduce
Using anonymous std::string initialization using std::filesystem::path, VS Code shows an error; however, I can successfully compile my project without any warnings or errors.
Example:
std::filesystem::path path1{"mypath.ext"};
std::filesystem::path path2(std::string("mypath.ext"));
std::filesystem::path path3 = path2 / "some";
std::filesystem::path path4 = path2;
path4.replace_extension(".ext");
path1:
[{
"resource": "/c:/Users/alekesej/Documents/Programming/app3d/src/app3d/io/asset.cpp",
"owner": "C/C++: IntelliSense",
"code": "289",
"severity": 8,
"message": "no instance of constructor \"std::__1::__fs::filesystem::path::path\" matches the argument list",
"source": "C/C++",
"startLineNumber": 339,
"startColumn": 40,
"endLineNumber": 339,
"endColumn": 40,
"relatedInformation": [
{
"startLineNumber": 339,
"startColumn": 40,
"endLineNumber": 339,
"endColumn": 40,
"message": "argument types are: (const char [11])",
"resource": "/C:/Users/alekesej/Documents/Programming/app3d/src/app3d/io/asset.cpp"
}
]
}]
path2 works; path3:
[{
"resource": "/c:/Users/alekesej/Documents/Programming/app3d/src/app3d/io/asset.cpp",
"owner": "C/C++: IntelliSense",
"code": "349",
"severity": 8,
"message": "no operator \"/\" matches these operands",
"source": "C/C++",
"startLineNumber": 342,
"startColumn": 49,
"endLineNumber": 342,
"endColumn": 49,
"relatedInformation": [
{
"startLineNumber": 342,
"startColumn": 49,
"endLineNumber": 342,
"endColumn": 49,
"message": "operand types are: std::__1::__fs::filesystem::path / const char [5]",
"resource": "/C:/Users/alekesej/Documents/Programming/app3d/src/app3d/io/asset.cpp"
},
{
"startLineNumber": 342,
"startColumn": 49,
"endLineNumber": 342,
"endColumn": 49,
"message": "function \"std::__1::__fs::filesystem::operator/\" does not match because argument #2 does not match parameter",
"resource": "/C:/Users/alekesej/Documents/Programming/app3d/src/app3d/io/asset.cpp"
},
{
"startLineNumber": 342,
"startColumn": 49,
"endLineNumber": 342,
"endColumn": 49,
"message": "built-in operator/(<promoted arithmetic>, <promoted arithmetic>) does not match because argument #1 does not match parameter",
"resource": "/C:/Users/alekesej/Documents/Programming/app3d/src/app3d/io/asset.cpp"
}
]
}]
path4:
[{
"resource": "/c:/Users/alekesej/Documents/Programming/app3d/src/app3d/io/asset.cpp",
"owner": "C/C++: IntelliSense",
"code": "415",
"severity": 8,
"message": "no suitable constructor exists to convert from \"const char [5]\" to \"std::__1::__fs::filesystem::path\"",
"source": "C/C++",
"startLineNumber": 345,
"startColumn": 37,
"endLineNumber": 345,
"endColumn": 37
}]
In all cases, if I replace "mystring" with std::string(mystring) it errors will disappear.
Configuration and Logs
In the debug log, I didn't see any details about it. Environment info:
loggingLevel: Debug
cpptools version (TypeScript): 1.17.5
cpptools version (native): 1.17.5.0
Autocomplete is enabled.
Error squiggles are enabled if all header dependencies are resolved.
Hover is enabled.
IntelliSense Engine = default.
LSP: cpptools/queryCompilerDefaults (id: 1)
Querying compiler for default C++ language standard using command line: C:\msys64\clang64\bin\gcc.exe -x c++ -E -dM nul
LSP: cpptools/didChangeCppProperties (id: 2)
LSP: cpptools/queryCompilerDefaults (id: 3)
Detected language standard version: c++17
Querying compiler's default target using command line: "C:\msys64\clang64\bin\gcc.exe" -dumpmachine
Compiler returned default target value: x86_64-w64-windows-gnu
Compiler query command line: C:\msys64\clang64\bin\gcc.exe -std=c17 -m64 -Wp,-v -fno-blocks -E -dM -x c nul
Attempting to get defaults from C compiler in "compilerPath" property: 'C:\msys64\clang64\bin\gcc.exe'
Compiler query command line: C:\msys64\clang64\bin\gcc.exe -std=c++17 -m64 -Wp,-v -fno-blocks -E -dM -x c++ nul
Attempting to get defaults from C++ compiler in "compilerPath" property: 'C:\msys64\clang64\bin\gcc.exe'
Code browsing service initialized
Querying compiler for default C++ language standard using command line: C:\msys64\clang64\bin\clang++.exe -x c++ -E -dM nul
Custom configuration provider 'CMake Tools' registered
Detected language standard version: c++17
Querying compiler's default target using command line: "C:\msys64\clang64\bin\clang++.exe" -dumpmachine
Compiler returned default target value: x86_64-w64-windows-gnu
Compiler query command line: C:\msys64\clang64\bin\clang++.exe -std=c++23 -m64 -Wp,-v -fno-blocks -E -dM -x c++ nul
Compiler query command line: C:\msys64\clang64\bin\clang++.exe -std=c++2b -m64 -Wp,-v -fno-blocks -E -dM -x c++ nul
LSP: cpptools/fileCreated: file:///c%3A/Users/alekesej/Documents/Programming/app3d/build/.cmake/api/v1/reply/cache-v2-e71d07b676ecc0c638a3.json
LSP: cpptools/fileCreated: file:///c%3A/Users/alekesej/Documents/Programming/app3d/build/.cmake/api/v1/reply/codemodel-v2-6a6e32ecd3a4c1d44d8e.json
LSP: cpptools/fileCreated: file:///c%3A/Users/alekesej/Documents/Programming/app3d/build/.cmake/api/v1/reply/index-2023-08-29T10-30-35-0049.json
LSP: cpptools/fileCreated: file:///c%3A/Users/alekesej/Documents/Programming/app3d/build/.cmake/api/v1/reply/target-app3d-Debug-1e7eed5e9f8692b7c018.json
LSP: cpptools/fileDeleted: file:///c%3A/Users/alekesej/Documents/Programming/app3d/build/.cmake/api/v1/reply/cache-v2-88c650da2ea2b8a70cfb.json
LSP: cpptools/fileDeleted: file:///c%3A/Users/alekesej/Documents/Programming/app3d/build/.cmake/api/v1/reply/index-2023-08-29T10-12-55-0139.json
LSP: cpptools/fileDeleted: file:///c%3A/Users/alekesej/Documents/Programming/app3d/build/.cmake/api/v1/reply/codemodel-v2-ecd965f35361ae2e590c.json
LSP: cpptools/fileDeleted: file:///c%3A/Users/alekesej/Documents/Programming/app3d/build/.cmake/api/v1/reply/target-app3d-Debug-b425a7ad3f8aa23defc2.json
Attempting to get defaults from C++ compiler in "compilerPath" property: 'C:\msys64\clang64\bin\clang++.exe'
Compiler query command line: C:\msys64\clang64\bin\clang++.exe -std=c17 -m64 -Wp,-v -fno-blocks -E -dM -x c nul
Attempting to get defaults from C compiler in "compilerPath" property: 'C:\msys64\clang64\bin\clang++.exe'
Folder: C:/MSYS64/CLANG64/INCLUDE/ will be indexed
Folder: C:/MSYS64/CLANG64/LIB/CLANG/16/INCLUDE/ will be indexed
Folder: C:/USERS/ALEKESEJ/DOCUMENTS/PROGRAMMING/APP3D/ will be indexed
Custom browse configuration received: {
"browsePath": [
/// Many items
],
"compilerPath": "c:/msys64/clang64/bin/clang++.exe",
"compilerArgs": [],
"compilerFragments": [
" -stdlib=libc++ -fexperimental-library -g",
"-std=c++2b"
]
}
Hi @wusikijeronii . Thanks for reporting this. It appears to be related to a bug in our IntelliSense engine, which is shared with Visual Studio. I've opened an internal bug against VS for this (1879043).
I can confirm this error also occurs on Visual Studio Code for macOS.
The code below compiles without issue, but Intellisense reports an error.
+1 macOS
same here on macOS, it also happen to std::move templates