Skip to content

hover over static constexpr variables does not show evaluation result #12284

@diablodale

Description

@diablodale

Environment

  • OS and Version: Microsoft Windows [Version 10.0.22631.3447]
  • VS Code Version: 1.89.0 (system setup)
  • C/C++ Extension Version: 1.19.9
  • If using SSH remote, specify OS of remote machine:

Bug Summary and Steps to Reproduce

Summary

Some combinations of static/not for constexpr formula are not evaluated by intellisense hover. Statements as static constexpr... sometimes do not evaluate.

Setup

  • as above
  • VS 2022 Community 17.9.6

Repro

  1. Create vscode folder, cmakelists.txt, to configure and compile below c++17 code
  2. Over over the 8 variable names to see which are evaluated and show their result
int main() {

    // hover over both variable names, left side of operator=() ...

    // shows 5 and 10
    constexpr int case1a = 5;
    constexpr int case1b = case1a * 2;

    // shows 5 and 10
    static constexpr int case2a = 5;
    constexpr int case2b = case2a * 2;

    // shows only 5
    constexpr int case3a = 5;
    static constexpr int case3b = case3a * 2;

    // shows only 5
    static constexpr int case4a = 5;
    static constexpr int case4b = case4a * 2;

    return 0;
}

Result

Only 6 of 8 variables have their results evaluated on hover. Two of the static constexpr... fail to show their result.

Expected

All 8 variables show their evaluated result on hover.

Configuration and Logs

No c_cpp_properties.json
-------- Diagnostics - 5/6/2024, 3:25:47 PM
Version: 1.19.9
Current Configuration:
{
    "name": "Win32",
    "includePath": [
        "c:/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/**"
    ],
    "defines": [
        "_DEBUG",
        "UNICODE",
        "_UNICODE"
    ],
    "windowsSdkVersion": "10.0.22621.0",
    "compilerPath": "cl.exe",
    "cStandard": "c17",
    "cppStandard": "c++17",
    "intelliSenseMode": "windows-msvc-x64",
    "compilerPathInCppPropertiesJson": "cl.exe",
    "intelliSenseModeIsExplicit": false,
    "cStandardIsExplicit": false,
    "cppStandardIsExplicit": false,
    "mergeConfigurations": false,
    "compilerPathIsExplicit": false,
    "configurationProvider": "ms-vscode.cmake-tools",
    "browse": {
        "path": [
            "c:/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/**",
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Custom browse configuration: 
{
    "browsePath": [
        "c:/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src",
        "c:/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/include"
    ],
    "compilerPath": "c:/program files/microsoft visual studio/2022/community/vc/tools/msvc/14.39.33519/bin/hostx64/x64/cl.exe",
    "compilerArgs": [],
    "compilerFragments": [
        "/DWIN32 /D_WINDOWS /EHsc /Ob0 /Od /RTC1 -std:c++17 -MDd -Zi"
    ]
}
cpptools version (native): 1.19.9.0
Translation Unit Mappings:
[ C:\repos-nobackup\cpptools-bug-hover-constexpr\my-cpp-project\include\other_classes.h - source TU]:
[ C:\repos-nobackup\cpptools-bug-hover-constexpr\my-cpp-project\src\main.cpp - source TU]:
Translation Unit Configurations:
[ C:\repos-nobackup\cpptools-bug-hover-constexpr\my-cpp-project\include\other_classes.h ]:
    Process ID: 11512
    Memory Usage: 49 MB
    Compiler Path: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\bin\Hostx64\x64\cl.exe
    Includes:
        C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include
        C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\atlmfc\include
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\winrt
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\cppwinrt
    Defines:
        WIN32
        _WINDOWS
    Standard Version: ms_c++17
    IntelliSense Mode: windows-msvc-x64
[ C:\repos-nobackup\cpptools-bug-hover-constexpr\my-cpp-project\src\main.cpp ]:
    Process ID: 31836
    Memory Usage: 54 MB
    Compiler Path: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\bin\Hostx64\x64\cl.exe
    Includes:
        C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include
        C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\atlmfc\include
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\winrt
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\cppwinrt
    Defines:
        WIN32
        _WINDOWS
    Standard Version: ms_c++17
    IntelliSense Mode: windows-msvc-x64
Total Memory Usage: 103 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 5032
loggingLevel: Debug
loggingLevel has changed to: Debug
LSP: (received) cpptools/fileCreated: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/.vscode
LSP: (invoked) cpptools/didChangeCppProperties (id: 1206)
LSP: Sending response (id: 1206)
LSP: (invoked) cpptools/fileCreated: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/.vscode
LSP: (received) cpptools/fileCreated: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/.vscode/settings.json
LSP: (invoked) cpptools/fileCreated: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/.vscode/settings.json
LSP: (received) cpptools/didChangeVisibleTextEditors
LSP: (invoked) cpptools/didChangeVisibleTextEditors
LSP: (received) cpptools/didChangeVisibleTextEditors
LSP: (invoked) cpptools/didChangeVisibleTextEditors
LSP: (received) cpptools/didChangeVisibleTextEditors
LSP: (invoked) cpptools/didChangeVisibleTextEditors
LSP: (received) cpptools/didChangeVisibleTextEditors
LSP: (invoked) cpptools/didChangeVisibleTextEditors
LSP: (received) cpptools/didChangeVisibleTextEditors
LSP: (invoked) cpptools/didChangeVisibleTextEditors
Intellisense update pending for: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src/main.cpp
LSP: (received) cpptools/didChangeActiveEditor: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src/main.cpp
LSP: (received) cpptools/getCodeActions: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src/main.cpp (id: 1207)
LSP: (invoked) cpptools/didChangeActiveEditor: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src/main.cpp
LSP: (received) cpptools/didChangeTextEditorSelection
LSP: (invoked) cpptools/getCodeActions: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src/main.cpp (id: 1207)
LSP: Sending response (id: 1207)
LSP: (invoked) cpptools/didChangeTextEditorSelection
IntelliSense update scheduled and TU acquisition started for: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src/main.cpp
Update IntelliSense time (sec): 0.002
LSP: (received) cpptools/getFoldingRanges: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src/main.cpp (id: 1208)
LSP: (invoked) cpptools/getFoldingRanges: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src/main.cpp (id: 1208)
LSP: Sending response (id: 1208)
LSP: (received) cpptools/getCodeActions: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src/main.cpp (id: 1209)
LSP: (invoked) cpptools/getCodeActions: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src/main.cpp (id: 1209)
LSP: Sending response (id: 1209)
LSP: (received) cpptools/getDocumentSymbols: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src/main.cpp (id: 1210)
LSP: (invoked) cpptools/getDocumentSymbols: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src/main.cpp (id: 1210)
LSP: Sending response (id: 1210)
LSP: (received) cpptools/didChangeVisibleTextEditors
LSP: (invoked) cpptools/didChangeVisibleTextEditors
LSP: (received) cpptools/didChangeActiveEditor: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src/main.cpp
LSP: (invoked) cpptools/didChangeActiveEditor: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src/main.cpp
LSP: (received) cpptools/didChangeVisibleTextEditors
LSP: (invoked) cpptools/didChangeVisibleTextEditors
LSP: (received) textDocument/hover: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src/main.cpp (id: 1211)
LSP: (invoked) textDocument/hover: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src/main.cpp (id: 1211)
LSP: Sending response (id: 1211)
LSP: $/cancelRequest (<unknown/completed>, id: 1211)
LSP: (received) textDocument/hover: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src/main.cpp (id: 1212)
LSP: (invoked) textDocument/hover: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src/main.cpp (id: 1212)
LSP: Sending response (id: 1212)
LSP: (received) textDocument/hover: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src/main.cpp (id: 1213)
LSP: (invoked) textDocument/hover: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src/main.cpp (id: 1213)
LSP: Sending response (id: 1213)
LSP: (received) textDocument/hover: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src/main.cpp (id: 1214)
LSP: (invoked) textDocument/hover: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src/main.cpp (id: 1214)
LSP: Sending response (id: 1214)
LSP: (received) textDocument/hover: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src/main.cpp (id: 1215)
LSP: (invoked) textDocument/hover: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src/main.cpp (id: 1215)
LSP: Sending response (id: 1215)
LSP: (received) textDocument/hover: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src/main.cpp (id: 1216)
LSP: (invoked) textDocument/hover: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src/main.cpp (id: 1216)
LSP: Sending response (id: 1216)
LSP: (received) textDocument/hover: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src/main.cpp (id: 1217)
LSP: (invoked) textDocument/hover: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src/main.cpp (id: 1217)
LSP: Sending response (id: 1217)
LSP: (received) textDocument/hover: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src/main.cpp (id: 1218)
LSP: (invoked) textDocument/hover: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src/main.cpp (id: 1218)
LSP: Sending response (id: 1218)
LSP: (received) textDocument/hover: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src/main.cpp (id: 1219)
LSP: (invoked) textDocument/hover: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src/main.cpp (id: 1219)
LSP: Sending response (id: 1219)
LSP: (received) textDocument/hover: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src/main.cpp (id: 1220)
LSP: (invoked) textDocument/hover: file:///c%3A/repos-nobackup/cpptools-bug-hover-constexpr/my-cpp-project/src/main.cpp (id: 1220)
LSP: Sending response (id: 1220)


### Other Extensions

_No response_

### Additional context

_No response_

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions