Skip to content

invalid type conversion IntelliSense #11294

Description

Environment

Windows 11
10.0.22621 Build 22621

  • VS Code Version: 1.80.2
  • C/C++ Extension Version: v1.16.3

Bug Summary and Steps to Reproduce

Open a .cpp file in vscode with this code

voidnormal_function(int number, char character) {}
intmain() {
(void*&)normal_function;
&(void*&)normal_function;
return0;
}

IntelliSense is reporting the following error, however the code compiles fine in MSVC

[{
"resource": "/C:/Test/bug_report/main.cpp",
"owner": "C/C++: IntelliSense",
"code": "171",
"severity": 8,
"message": "invalid type conversion",
"source": "C/C++",
"startLineNumber": 4,
"startColumn": 4,
"endLineNumber": 4,
"endColumn": 8
}]

In fact the same error is seeing in visual studio 2022 but again the code compiles without any problem

Configuration and Logs

Logs:
loggingLevel: Debug
cpptools version (TypeScript): 1.16.3
cpptools version (native): 1.16.3.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)
LSP: cpptools/didChangeCppProperties (id: 2)
LSP: cpptools/textEditorSelectionChange
Code browsing service initialized
Folder: C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2019/BUILDTOOLS/VC/TOOLS/MSVC/14.29.30133/INCLUDE/* will be indexed
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:/TEST/BUG_REPORT/ will be indexed
Folder: C:/UTILS/VCPKG/INSTALLED/X64-WINDOWS/INCLUDE/ will be indexed
Folder: C:/UTILS/VCPKG/INSTALLED/X86-WINDOWS/INCLUDE/ will be indexed
Discovering files...
Processing folder (non-recursive): C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2019/BUILDTOOLS/VC/TOOLS/MSVC/14.29.30133/INCLUDE
Processing folder (recursive): C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22621.0/CPPWINRT/
LSP: textDocument/didOpen: file:///c%3A/Test/bug_report/main.cpp
Processing folder (recursive): C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22621.0/SHARED/
LSP: cpptools/activeDocumentChange: file:///c%3A/Test/bug_report/main.cpp
Processing folder (recursive): C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22621.0/UCRT/
LSP: cpptools/getInlayHints: file:///c%3A/Test/bug_report/main.cpp (id: 3)
Processing folder (recursive): C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22621.0/UM/
LSP: cpptools/getDocumentSymbols: file:///c%3A/Test/bug_report/main.cpp (id: 4)
LSP: cpptools/getFoldingRanges: file:///c%3A/Test/bug_report/main.cpp (id: 5)
LSP: cpptools/textEditorSelectionChange
LSP: cpptools/activeDocumentChange: file:///c%3A/Test/bug_report/main.cpp
c:\Users\raigo\.vscode\extensions\ms-vscode.cpptools-1.16.3-win32-x64/bin/../LLVM/bin/clang-tidy.exe
--header-filter=(C:/Test/bug_report|C:\\Test\\bug_report)
--export-fixes=C:\Users\raigo\AppData\Local\Temp\{8696044937690906415}\fixes31664.yaml
--quiet
--use-color=false
C:/Test/bug_report/main.cpp
-p=C:/Test/bug_report
Processing folder (recursive): C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22621.0/WINRT/
Processing folder (recursive): C:/TEST/BUG_REPORT/
Processing folder (recursive): C:/UTILS/VCPKG/INSTALLED/X64-WINDOWS/INCLUDE/
Processing folder (recursive): C:/UTILS/VCPKG/INSTALLED/X86-WINDOWS/INCLUDE/
Discovering files: 5127 file(s) processed
0 file(s) removed from database
Done discovering files.
Populating include completion cache.
Parsing remaining files...
Parsing: 0 files(s) processed
Done parsing remaining files.
sending compilation args for C:\Test\bug_report\main.cpp
include: C:\UTILS\VCPKG\INSTALLED\X64-WINDOWS\INCLUDE
include: C:\UTILS\VCPKG\INSTALLED\X86-WINDOWS\INCLUDE
include: C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\BUILDTOOLS\VC\TOOLS\MSVC\14.29.30133\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: UNICODE
define: _UNICODE
stdver: ms_c++20
intelliSenseMode: windows-msvc-x64
Checking for syntax errors: C:\Test\bug_report\main.cpp
Queueing IntelliSense update forfilesin translation unit of: C:\Test\bug_report\main.cpp
LSP: cpptools/getSemanticTokens: file:///c%3A/Test/bug_report/main.cpp (id: 6)
Error while trying to load a compilation database:
Could not auto-detect compilation database from directory "C:/Test/bug_report"
No compilation database found in C:\Test\bug_report or any parent directory
fixed-compilation-database: Error while opening fixed database: no such file or directory
json-compilation-database: Error while opening JSON database: no such file or directory
Running without flags.
C:\Test\bug_report\main.cpp:4:3: warning: expression result unused [clang-diagnostic-unused-value]
(void*&)normal_function;
^ ~~~~~~~~~~~~~~~
C:\Test\bug_report\main.cpp:6:3: warning: expression result unused [clang-diagnostic-unused-value]
&(void*&)normal_function;
^~~~~~~~~~~~~~~~~~~~~~~~
Error squiggle count: 2
Update IntelliSense time (sec): 0.456
LSP: cpptools/textEditorSelectionChange
LSP: cpptools/getFoldingRanges: file:///c%3A/Test/bug_report/main.cpp (id: 7)
LSP: cpptools/getCodeActions: file:///c%3A/Test/bug_report/main.cpp (id: 8)
LSP: cpptools/getCodeActions: file:///c%3A/Test/bug_report/main.cpp (id: 9)
LSP: cpptools/getDocumentSymbols: file:///c%3A/Test/bug_report/main.cpp (id: 10)
LSP: cpptools/getFoldingRanges: file:///c%3A/Test/bug_report/main.cpp (id: 11)
LSP: cpptools/getCodeActions: file:///c%3A/Test/bug_report/main.cpp (id: 12)
LSP: cpptools/getCodeActions: file:///c%3A/Test/bug_report/main.cpp (id: 13)
LSP: cpptools/getCodeActions: file:///c%3A/Test/bug_report/main.cpp (id: 14)
LSP: cpptools/getDocumentSymbols: file:///c%3A/Test/bug_report/main.cpp (id: 15)
LSP: cpptools/getFoldingRanges: file:///c%3A/Test/bug_report/main.cpp (id: 16)
Unable to find cl.exe. C/C++: cl.exe build active file task is ignored.
LSP: cpptools/getCodeActions: file:///c%3A/Test/bug_report/main.cpp (id: 17)
LSP: cpptools/getDocumentSymbols: file:///c%3A/Test/bug_report/main.cpp (id: 18)
LSP: cpptools/getFoldingRanges: file:///c%3A/Test/bug_report/main.cpp (id: 19)
LSP: cpptools/textEditorSelectionChange
LSP: cpptools/getCodeActions: file:///c%3A/Test/bug_report/main.cpp (id: 20)
LSP: cpptools/textEditorSelectionChange
LSP: cpptools/getCodeActions: file:///c%3A/Test/bug_report/main.cpp (id: 21)
LSP: cpptools/textEditorSelectionChange
LSP: cpptools/getCodeActions: file:///c%3A/Test/bug_report/main.cpp (id: 22)
LSP: cpptools/textEditorSelectionChange
LSP: cpptools/textEditorSelectionChange
LSP: cpptools/getCodeActions: file:///c%3A/Test/bug_report/main.cpp (id: 23)
LSP: cpptools/getCodeActions: file:///c%3A/Test/bug_report/main.cpp (id: 24)
LSP: cpptools/textEditorSelectionChange
LSP: cpptools/activeDocumentChange: file:///c%3A/Test/bug_report/main.cpp

Other Extensions

No response

Additional context

Seems to compile fine in every major compiler, no idea if this casting its allowed in the standard
https://godbolt.org/z/7d7WMTE91

Metadata

Metadata

Labels

Language ServiceVisual StudioInherited from Visual StudiobugfixedCheck the Milestone for the release in which the fix is or will be available.

Type

Projects

Status
Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions