Steps to Reproduce:
The following code seems giving vscode a hard time to parse -
// hist_bins is vector container
auto idx = std::lower_bound(hist_bins.begin(), hist_bins.end(), val) - hist_bins.begin();
I think this is valid code, isn't it?
{
"resource": "/Users/xyz/test.cc",
"owner": "_generated_diagnostic_collection_name_#0",
"code": "undefined",
"severity": 8,
"message": "more than one operator \"-\" matches these operands: -- function template \"auto std::__1::operator-(const std::__1::__wrap_iter<_Iter1> &__x, const std::__1::__wrap_iter<_Iter2> &__y)-><error-type>\" -- function template \"auto std::__1::operator-(const std::__1::__wrap_iter<_Iter1> &__x, const std::__1::__wrap_iter<_Iter2> &__y)->decltype(((__x.std::__1::__wrap_iter<_Iter>::base()) - (__y.std::__1::__wrap_iter<_Iter>::base())))\" -- operand types are: std::__1::__wrap_iter<uint64_t *> - std::__1::__wrap_iter<uint64_t *>",
"startLineNumber": 125,
"startColumn": 78,
"endLineNumber": 125,
"endColumn": 78
}
Does this issue occur when all extensions are disabled?: Yes/No
Thanks for reporting this. Yeah, it looks like an issue particular to the Mac clang 10.0 since I'm not seeing it with cl.exe/gcc or clang 3.9 (which I think corresponds to Mac clang 9).
I tried the following the modification, setting a different compiler path (gcc@8 installed by homebrew), the error still shows up.
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"macFrameworkPath": [
"/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/local/bin/gcc-8",
"configurationProvider": "vector-of-bool.cmake-tools"
}
],
"version": 4
}
You have a configurationProvider set, which will use that to determine the includePath for system headers, ignoring the compilerPath. Setting your C_Cpp.loggingLevel to "Debug" should allow you to see what include paths are actually being used in the C/C++ output window (I'm not sure if homebrew gcc on Mac will use the clang libc++ header still). I'm not seeing this error with gcc-8 on Linux:

I filed a bug with Visual Studio at https://developercommunity.visualstudio.com/content/problem/374666/c-intellisense-reports-incorrect-more-than-one-ope.html .
I got a simpler isolated repro:
template <class T> class TC;
// The bug doesn't repro when this declaration is omitted.
template <class T>
auto operator-(TC<T> x, TC<T> y) -> decltype(x.base() - y.base());
template <class T>
struct TC
{
int base() { return 0; }
};
template <class T>
auto operator-(TC<T> x, TC<T> y) -> decltype(x.base() - y.base())
{
return x.base() - y.base();
}
int main()
{
TC<int*> i, j;
return i - j; // error here.
}
This incorrect IntelliSense error squiggle with clang 10 libraries should be fixed now with our latest Insiders release: https://github.com/Microsoft/vscode-cpptools/releases . If you're using VS Code Insiders or have http.proxySupport not set to "off", you might not get the 0.21.0-insiders2 update automatically with C_Cpp.updateChannel set to "Insiders".
Most helpful comment
This incorrect IntelliSense error squiggle with clang 10 libraries should be fixed now with our latest Insiders release: https://github.com/Microsoft/vscode-cpptools/releases . If you're using VS Code Insiders or have http.proxySupport not set to "off", you might not get the 0.21.0-insiders2 update automatically with C_Cpp.updateChannel set to "Insiders".