microsoft / microsoft/vscode-cpptools

The computation of `sizeof` is not accurate for structs with bit-fields.

Open
#7,495 3 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Bug type: Language Service

  • OS and Version: Ubuntu 20.0.4 5.8.0-49-generic x64
  • VS Code Version: 1.56
  • C/C++ Extension Version: 1.3.1

Steps to reproduce
Code on godbolt: https://godbolt.org/z/KbjrEnP4s
Screenshot from 2021-05-09 14-30-02

Expected behavior
On sizeof-hover must be displayed 8 bytes.

Logs

  • Configurations in c_cpp_properties.json:
{
  "configurations": [
    {
      "name": "Linux",
      "includePath": ["${workspaceFolder}/**"],
      "defines": [],
      "compilerPath": "/usr/bin/clang-12",
      "compilerArgs": ["-std=c2x", "-march=native"],
      "intelliSenseMode": "linux-clang-x64",
      "cStandard": "c17",
      "cppStandard": "c++20"
    }
  ],
  "version": 4
}

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

Open the Godbolt reproduction linked in the issue and review the supplied c_cpp_properties.json settings, especially the clang compiler and C/C++ standards. Reproduce the sizeof hover for the struct with bit-fields and compare the displayed value with the expected 8 bytes; done means the hover reports 8 bytes for that case.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.