vscode-cpptools
vscode-cpptools copied to clipboard
Incorrect diagnostic for operator <=>
Bug type: Language Service
Describe the bug
- OS and Version: Windows 11, Build 22598.ni_release.220408-1503
- VS Code Version: 1.66.2 (system setup)
- C/C++ Extension Version: 1.9.7
- Other extensions you installed (and if the issue persists after disabling them): all deactivated, issue persists
- Compiler Version: MSVC 19.31.31106.2
Steps to reproduce
- Open "Developer PowerShell for VS 2022" and run "code"
- Open a folder with file "./wrap.cpp", "./.vscode/c_cpp_properties.json" (offered below)
- See incorrect diagnostic
more than one operator "<=>" matches these operands:C/C++(350)
wrap.cpp(17, 17): function template "auto wrap<T>::operator<=>(const wrap<U> &other) [with T=float]" (declared at line 8), with reversed arguments
wrap.cpp(17, 17): function template "auto wrap<T>::operator<=>(const wrap<U> &other) [with T=double]" (declared at line 8)
wrap.cpp(17, 17): operand types are: wrap<double> <=> wrap<float>
+2 similar diagnostic
- The code can compile with no diagnostic
cl wrap.cpp /std:c++latest /EHsc /permissive- /W4 /nologo
Expected behavior
No issue any diagnostic
Code sample and logs
- Code sample: wrap.cpp
#include <iostream>
template <typename T>
struct wrap {
T data;
template <typename U>
auto operator<=>(const wrap<U> &other) {
return data <=> other.data;
}
};
int main() {
using std::cout, std::endl;
wrap<double> a { 1.0 };
wrap<float> b { 2.0f };
cout << ((a <=> b) < 0) << endl;
cout << ((a <=> b) == 0) << endl;
cout << ((a <=> b) > 0) << endl;
}
- Configurations in
c_cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.19041.0",
"compilerPath": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.31.31103/bin/Hostx64/x64/cl.exe",
"cStandard": "c17",
"cppStandard": "c++20",
"intelliSenseMode": "windows-msvc-x64"
}
],
"version": 4
}
@michelleangela I repro the issue with VS -- were you going to file a bug on them, either externally or internally? It a C++20 or C++23 issue so I'm thinking it'll be high priority for them to fix.
@michelleangela You may not have reproed it earlier in VS, because they had a bug which was causing squiggles to disappear, which got fixed recently.
Created feedback bug on VS https://developercommunity.visualstudio.com/t/Incorrect-C-IntelliSense-diagnostic-fo/10050557.
Fixed with https://github.com/microsoft/vscode-cpptools/releases/tag/v1.12.1