Skip to content

Find All References on a variable template returns nothing #14631

Description

@lukka

Environment

cpptools — Find All References on the variable template ex::zeroValue returns nothing

Field Value
Symbol (spec id) var-template-zeroValue
Declaration template <class T> constexpr T zeroValue = T(0); (variable template)
Query position src/extras.h:22:13 (cursor on zeroValue)
Affected LSP request textDocument/references
Repro archive P1-var-template-zeroValue.zip (this folder)

Summary

Find All References on the variable template ex::zeroValue returns no references in VS Code with the C/C++ extension (cpptools), missing both instantiation uses. The symbol appears unused even though it is instantiated twice.

Environment

  • Editor: Visual Studio Code 1.33.5
  • Extension: C/C++ (ms-vscode.cpptools), default IntelliSense engine
  • Language standard: C++20 (freestanding fixture; no STL/toolchain required)

Steps to reproduce

  1. Extract P1-var-template-zeroValue.zip and open the cpp-project folder in VS Code (C/C++ extension enabled).
  2. Optionally configure with CMake Tools (preset cdb); the fixture also parses under default C++20 IntelliSense.
  3. Open src/extras.h, place the cursor on zeroValue in constexpr T zeroValue = T(0); (line 22, col 13).
  4. Invoke Find All References (Shift+Alt+F12).

Expected vs actual

Source Result count
Expected 3
VS Code / cpptools 0 (no references)

Expected (3): the template declaration (extras.h:22) and its two instantiation uses in main()ex::zeroValue<int> (main.cpp:150) and ex::zeroValue<double> (main.cpp:151).

Actual (0): "Find All References" reports no results (the instantiation uses are not found).

Why it matters

A false "no references" on a live symbol is high risk: an automated agent (or a developer) can conclude the variable template is dead and delete it, breaking the two instantiations.

Bug Summary and Steps to Reproduce

P1-var-template-zeroValue.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions