microsoft / microsoft/vscode-cpptools

Function type instance: Go to definition of function type goes to return type

Open
#13,433 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Language Service Visual Studio
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Environment
  • OS and Version: Linux x64 6.13.8-arch1-1
  • VS Code Version: 1.98.2
  • C/C++ Extension Version: 1.24.3
  • If using SSH remote, specify OS of remote machine:
Bug Summary and Steps to Reproduce

Bug Summary:
With this minimal example of defining a function type, declaring an instance of this type, and finally defining this function, one of the examples fails to go to definition (F12) or show it upon hover:

using Foo = void;
using RetFoo = Foo();
RetFoo retFoo; // hover wrong: using Foo = void
Foo retFoo() {}

RetFoo retFooUndefined; // hover correct: using RetFoo = Foo ()

using RetVoid = void();
RetVoid retVoid; // hover correct: using RetVoid = void ()
void retVoid() {}

Instead of showing the definition of the (function) type, it shows the return type of the function.

It only happens:

  • when the function definition has been added.
  • If the return type is not a fundamental such as void or int

Steps to reproduce:

  1. Open the code above in the editor
  2. Go to definition of RetFoo in the declaration RetFoo retFoo;
Configuration and Logs
-------- Diagnostics - 3/27/2025, 8:00:29 PM
Version: 1.24.3
Current Configuration:
{
    "name": "Linux",
    "includePath": [
        "${workspaceFolder}/**"
    ],
    "defines": [],
    "cStandard": "c17",
    "cppStandard": "c++17",
    "intelliSenseMode": "linux-clang-x64",
    "intelliSenseModeIsExplicit": false,
    "cStandardIsExplicit": false,
    "cppStandardIsExplicit": false,
    "mergeConfigurations": false,
    "compilerPath": "/usr/bin/g++",
    "compilerPathIsExplicit": true,
    "browse": {
        "limitSymbolsToIncludedHeaders": true
    }
}
Modified Settings:
{
    "C_Cpp.default.compilerPath": "/usr/bin/g++",
    "C_Cpp.codeAnalysis.clangTidy.enabled": true,
    "C_Cpp.codeAnalysis.clangTidy.checks.enabled": [
        "cppcoreguidelines-*",
        "performance-*",
        "modernize-*"
    ],
    "C_Cpp.codeAnalysis.clangTidy.checks.disabled": [
        "altera-id-dependent-backward-branch",
        "altera-unroll-loops",
        "android-*",
        "bugprone-easily-swappable-parameters",
        "bugprone-implicit-widening-of-multiplication-result",
        "cert-dcl58-cpp",
        "cert-err33-c",
        "cppcoreguidelines-avoid-magic-numbers",
        "cppcoreguidelines-non-private-member-variables-in-classes",
        "cppcoreguidelines-pro-bounds-pointer-arithmetic",
        "cppcoreguidelines-pro-type-reinterpret-cast",
        "cppcoreguidelines-pro-type-vararg",
        "fuchsia-*",
        "google-readability-*",
        "google-runtime-int",
        "hicpp-vararg",
        "llvm-header-guard",
        "llvmlibc-*",
        "misc-include-cleaner",
        "misc-non-private-member-variables-in-classes",
        "performance-unnecessary-value-param",
        "readability-identifier-length",
        "readability-magic-numbers"
    ],
    "C_Cpp.loggingLevel": "Debug",
    "C_Cpp.autoAddFileAssociations": false
}
Additional Tracked Settings:
{
    "editorTabSize": 4,
    "editorInsertSpaces": true,
    "editorAutoClosingBrackets": "languageDefined",
    "filesEncoding": "utf8",
    "filesAssociations": {},
    "filesExclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/.DS_Store": true,
        "**/Thumbs.db": true
    },
    "filesAutoSaveAfterDelay": false,
    "editorInlayHintsEnabled": true,
    "editorParameterHintsEnabled": true,
    "searchExclude": {
        "**/node_modules": true,
        "**/bower_components": true,
        "**/*.code-search": true
    },
    "workbenchSettingsEditor": "ui"
}
cpptools version (native): 1.24.3.0
Current database path: /tmp/{8585037B-B0F4-4459-99C4-3FBEE7EA3BC6}/.browse.VC.db
Translation Unit Mappings:
[ /home/per/ftype.hpp - source TU]:
Translation Unit Configurations:
[ /home/per/ftype.hpp ]
    Process ID: 960004
    Memory Usage: 20 MB
    Compiler Path: /usr/bin/g++
    Include paths:
        system include: /usr/include/c++/14.2.1
        system include: /usr/include/c++/14.2.1/x86_64-pc-linux-gnu
        system include: /usr/include/c++/14.2.1/backward
        system include: /usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/include
        system include: /usr/local/include
        system include: /usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/include-fixed
        system include: /usr/include
    Standard Version: c++17
    IntelliSense Mode: linux-gcc-x64
    Other Flags:
        --g++
        --gnu_version=140201
Total Memory Usage: 20 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 38903
Other Extensions

No response

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal reproduction in ftype.hpp and reproduce F12 and hover on RetFoo in the retFoo declaration using the reported Linux, C++17, and g++ configuration. Trace the definition lookup for the function-type alias and verify that it resolves to using RetFoo = Foo() rather than the return type, including the reported cases where the function definition exists and the return type is non-fundamental.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.