microsoft / microsoft/vscode-cpptools

IntelliSense: constexpr give wrong result.

Open
#11,916 2 comments 0 reactions 1 assignee View on GitHub

@browntarik is already working on this.

Since Feb 5, 2024.

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

Description

Environment
  • OS and Version: Ubuntu 22.04.3 LTS
  • VS Code Version: 1.85.1
  • C/C++ Extension Version: 1.19.2
  • If using SSH remote, specify OS of remote machine:
Bug Summary and Steps to Reproduce

constexpr give wrong result.

#include <cstdio>
#include <memory>

int main(int argc, char* argv[]) {
    constexpr const size_t t0 = sizeof(std::unique_ptr<int>);
    printf("t0: %zu\n", t0);
    return 0;
}

IntelliSense show 16, but actually it is 8.
截图 2024-02-02 23-58-52

Configuration and Logs
Log:
-------- Diagnostics - 2024/2/3 00:06:58
Version: 1.19.2
Current Configuration:
{
    "name": "Linux",
    "includePath": [
        "/home/llc/下载/my/test0/**"
    ],
    "defines": [],
    "compilerPath": "/usr/bin/clang",
    "cStandard": "c17",
    "cppStandard": "c++14",
    "intelliSenseMode": "linux-clang-x64",
    "compilerPathInCppPropertiesJson": "/usr/bin/clang",
    "intelliSenseModeIsExplicit": false,
    "cStandardIsExplicit": false,
    "cppStandardIsExplicit": false,
    "mergeConfigurations": false,
    "compilerPathIsExplicit": false,
    "configurationProvider": "ms-vscode.cmake-tools",
    "browse": {
        "path": [
            "/home/llc/下载/my/test0/**",
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Custom browse configuration: 
{
    "browsePath": [
        "/home/llc/下载/my/3rd/boost_1_84_0",
        "/home/llc/下载/my/test0"
    ],
    "compilerPath": "/usr/bin/g++",
    "compilerArgs": [],
    "compilerFragments": [
        "-g -std=gnu++17"
    ]
}
cpptools version (native): 1.19.2.0
Translation Unit Mappings:
[ /home/llc/下载/my/test0/Main.cpp - source TU]:
Translation Unit Configurations:
[ /home/llc/下载/my/test0/Main.cpp ]:
    Process ID: 7035
    Memory Usage: 58 MB
    Compiler Path: /usr/bin/g++
    Includes:
        /home/llc/下载/my/3rd/boost_1_84_0
        /usr/include/c++/11
        /usr/include/x86_64-linux-gnu/c++/11
        /usr/include/c++/11/backward
        /usr/lib/gcc/x86_64-linux-gnu/11/include
        /usr/local/include
        /usr/include/x86_64-linux-gnu
        /usr/include
    Standard Version: c++17
    IntelliSense Mode: linux-gcc-x64
    Other Flags:
        --g++
        --gnu_version=110400
Total Memory Usage: 58 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 83034
Number of files parsed: 36252
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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.