microsoft / microsoft/vscode-cpptools
The computation of `sizeof` is not accurate for structs with bit-fields.
Open
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

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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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