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

C/C++ extension flags error with std::bind, but code compiles without error #10304

Closed
jimorc opened this issue Dec 21, 2022 · 7 comments
Closed
Assignees
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service verified Bug has been reproduced
Milestone

Comments

@jimorc
Copy link

jimorc commented Dec 21, 2022

Environment

  • Windows 11 insider build 25267
  • VS Code Version: 1.74.2
  • C/C++ Extension Version: 1.13.8
  • running in VMWare Fusion 13 on M1 MacOS 13.1

Bug Summary and Steps to Reproduce

Bug Summary:
std::function<...> f = std::bind(...) is flagged by Cpptools with error:
no suitable user-defined conversion from "std::_Binder<std::_Unforced, int (A::*)(int x), A *, const std::_Ph<1> &>" to "std::function<int (int)>" existsC/C++(312)

but it compiles with MSVC from latest Visual Studio Community edition tools, and executes properly.
Disabling Cpptools removed the error.

Here is a program that illustrated the problem:

#include <functional>
#include <iostream>
using namespace std::placeholders;

class A
{
    public:
        int add2(int x) { return x + 2; }
};
int main()
{
    A a;
    std::function<int(int)> f = std::bind(&A::add2, &a, _1);
    std::cout << f(3) << '\n';
}
  1. Build the program using VS Code with Cpptools enabled. No build errors are reported.
  2. In VS Code, open the source file. The std::bind call is flagged with the error.
  3. Disable Cpptools. Click on Reload Required button. The std::bind call is no longer flagged.

Expected behavior:
The std::bind call should not be flagged by Cpptools.

Configuration and Logs

No c_cpp_properties.json file.

Log Diagnostics:
{
  "os": "win32",
  "vscodeVersion": "1.74.2",
  "cmtVersion": "1.12.27",
  "configurations": [
    {
      "folder": "c:\\Users\\Jim\\source",
      "cmakeVersion": "3.24.202208181",
      "configured": true,
      "generator": "Visual Studio 17 2022",
      "usesPresets": false,
      "compilers": {}
    }
  ],
  "cpptoolsIntegration": {
    "isReady": false,
    "hasCodeModel": false,
    "activeBuildType": "",
    "buildTypesSeen": [],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 0,
    "executablesCount": 0,
    "librariesCount": 0,
    "targets": []
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": true
    }
  ]
}

C++ logging:
loggingLevel: Debug
Custom browse configuration received: {
  "browsePath": [
    "c:/users/jim/source/build/cmakefiles/63a8a52bcd7fa1e0db6e090a8dad8b4a",
    "c:/users/jim/source"
  ],
  "compilerPath": "c:/program files/microsoft visual studio/2022/community/vc/tools/msvc/14.34.31933/bin/hostx64/arm64/cl.exe",
  "compilerFragments": [
    "/DWIN32 /D_WINDOWS /EHsc /Zi /Ob0 /Od /RTC1 -MDd"
  ],
  "compilerArgsLegacy": []
}
cpptools/didChangeCppProperties
Code browsing service initialized
Attempting to get defaults from C++ compiler in "compilerPath" property: 'C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe'
Attempting to get defaults from C compiler in "compilerPath" property: 'C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe'
  Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22621.0/CPPWINRT/ will be indexed
  Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22621.0/SHARED/ will be indexed
  Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22621.0/UCRT/ will be indexed
  Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22621.0/UM/ will be indexed
  Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22621.0/WINRT/ will be indexed
  Folder: C:/PROGRAM FILES/MICROSOFT VISUAL STUDIO/2022/COMMUNITY/VC/TOOLS/MSVC/14.34.31933/ATLMFC/INCLUDE/* will be indexed
  Folder: C:/PROGRAM FILES/MICROSOFT VISUAL STUDIO/2022/COMMUNITY/VC/TOOLS/MSVC/14.34.31933/INCLUDE/* will be indexed
  Folder: C:/USERS/JIM/SOURCE/ will be indexed
cpptools/didChangeCustomBrowseConfiguration
Discovering files...
Attempting to get defaults from C++ compiler in "compilerPath" property: 'c:/program files/microsoft visual studio/2022/community/vc/tools/msvc/14.34.31933/bin/hostx64/arm64/cl.exe'
  Folder: C:/PROGRAM FILES/MICROSOFT VISUAL STUDIO/2022/COMMUNITY/VC/TOOLS/MSVC/14.34.31933/INCLUDE/* will be indexed
  Folder: C:/PROGRAM FILES/MICROSOFT VISUAL STUDIO/2022/COMMUNITY/VC/TOOLS/MSVC/14.34.31933/ATLMFC/INCLUDE/* will be indexed
  Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22621.0/UM/ will be indexed
  Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22621.0/UCRT/ will be indexed
  Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22621.0/SHARED/ will be indexed
  Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22621.0/WINRT/ will be indexed
  Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22621.0/CPPWINRT/ will be indexed
  Folder: C:/USERS/JIM/SOURCE/ will be indexed
cpptools/clearCustomConfigurations
  Discovering files: 0 file(s) processed
Done discovering files.
Discovering files...
  Processing folder (non-recursive): C:/PROGRAM FILES/MICROSOFT VISUAL STUDIO/2022/COMMUNITY/VC/TOOLS/MSVC/14.34.31933/INCLUDE
  Processing folder (non-recursive): C:/PROGRAM FILES/MICROSOFT VISUAL STUDIO/2022/COMMUNITY/VC/TOOLS/MSVC/14.34.31933/ATLMFC/INCLUDE
  Processing folder (recursive): C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22621.0/UM/
  Processing folder (recursive): C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22621.0/UCRT/
  Processing folder (recursive): C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22621.0/SHARED/
  Processing folder (recursive): C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22621.0/WINRT/
  Processing folder (recursive): C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22621.0/CPPWINRT/
  Processing folder (recursive): C:/USERS/JIM/SOURCE/
  Discovering files: 6331 file(s) processed
  0 file(s) removed from database
Done discovering files.
Populating include completion cache.
Parsing remaining files...
  tag parsing file: C:\Users\Jim\source\bind.cpp
  Parsing: 143 files(s) processed
Done parsing remaining files.
cpptools/getSemanticTokens: C:\Users\Jim\source\bind.cpp (id: 2)

Other Extensions

All other extensions disabled. Bug still there.

Additional context

No response

@sean-mcmanus
Copy link
Collaborator

You appear to have provided the CMake Tools Log Diagnostics instead of the C/C++ extension Log Diagnostics -- can you provide our logs? In particular, I'm not reproing the bug (yet), so I was looking for a configuration setting that might be required.

@sean-mcmanus sean-mcmanus self-assigned this Dec 27, 2022
@sean-mcmanus sean-mcmanus added Language Service more info needed The issue report is not actionable in its current state not reproing We're not able to reproduce the issue (it's unlikely to get fixed until we find one). labels Dec 27, 2022
@sean-mcmanus
Copy link
Collaborator

Also, your C/C++ logging doesn't show any file being opened (so no IntelliSense for the file).

@jimorc
Copy link
Author

jimorc commented Dec 30, 2022

cpptools/queryTranslationUnitSource: C:\Users\Jim\source\bind.cpp (id: 144)
Custom configurations received:
uri: file:///c%3A/Users/Jim/source/bind.cpp
config: {
"includePath": [],
"defines": [],
"compilerPath": "c:/program files/microsoft visual studio/2022/community/vc/tools/msvc/14.34.31933/bin/hostx64/arm64/cl.exe",
"compilerArgs": [],
"compilerFragments": [
"/DWIN32 /D_WINDOWS /EHsc /Zi /Ob0 /Od /RTC1 -MDd",
"-std:c++17"
]
}
cpptools/didChangeCustomConfiguration
Attempting to get defaults from C++ compiler in "compilerPath" property: 'c:/program files/microsoft visual studio/2022/community/vc/tools/msvc/14.34.31933/bin/hostx64/arm64/cl.exe'
textDocument/didOpen: C:\Users\Jim\source\bind.cpp
cpptools/textEditorSelectionChange
cpptools/getCodeActions: C:\Users\Jim\source\bind.cpp (id: 145)
cpptools/getDocumentSymbols: C:\Users\Jim\source\bind.cpp (id: 146)
cpptools/textEditorSelectionChange
cpptools/getDocumentSymbols
cpptools/activeDocumentChange: C:\Users\Jim\source\bind.cpp
cpptools/getSemanticTokens: C:\Users\Jim\source\bind.cpp (id: 147)
cpptools/getInlayHints: C:\Users\Jim\source\bind.cpp (id: 148)
Database safe to open
sending compilation args for C:\Users\Jim\source\bind.cpp
include: C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\VC\TOOLS\MSVC\14.34.31933\INCLUDE
include: C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\VC\TOOLS\MSVC\14.34.31933\ATLMFC\INCLUDE
include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\UM
include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\UCRT
include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\SHARED
include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\WINRT
include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\CPPWINRT
define: _DEBUG
define: _MT
define: _DLL
define: WIN32
define: _WINDOWS
stdver: ms_c++17
intelliSenseMode: windows-msvc-arm64
Checking for syntax errors: C:\Users\Jim\source\bind.cpp
Queueing IntelliSense update for files in translation unit of: C:\Users\Jim\source\bind.cpp
cpptools/getFoldingRanges: C:\Users\Jim\source\bind.cpp (id: 149)
cpptools/getCodeActions: C:\Users\Jim\source\bind.cpp (id: 150)
cpptools/finishUpdateSquiggles
Error squiggle count: 1
Update IntelliSense time (sec): 0.892
cpptools/getFoldingRanges: C:\Users\Jim\source\bind.cpp (id: 151)
cpptools/getCodeActions: C:\Users\Jim\source\bind.cpp (id: 152)

@jimorc
Copy link
Author

jimorc commented Dec 30, 2022

The problem exists for C++17 and earlier. No problem with C++20.

@sean-mcmanus sean-mcmanus added bug verified Bug has been reproduced and removed more info needed The issue report is not actionable in its current state not reproing We're not able to reproduce the issue (it's unlikely to get fixed until we find one). labels Dec 31, 2022
@sean-mcmanus
Copy link
Collaborator

Okay, I repro it now -- it only repros with the windows-msvc-arm64 intelliSenseMode and not the windows-msvc-x64 mode.

@sean-mcmanus sean-mcmanus added this to the 1.14.0 milestone Dec 31, 2022
@sean-mcmanus sean-mcmanus added the fixed Check the Milestone for the release in which the fix is or will be available. label Dec 31, 2022
@sean-mcmanus
Copy link
Collaborator

This is already fixed in our pending 1.14.0 update (we may release it in a week or two, not sure).

@sean-mcmanus
Copy link
Collaborator

The fix is available with 1.14.0 (pre-release): https://github.com/microsoft/vscode-cpptools/releases/tag/v1.14.0

@github-actions github-actions bot locked and limited conversation to collaborators Apr 1, 2023
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 verified Bug has been reproduced
Projects
None yet
Development

No branches or pull requests

2 participants