Open ytxmobile98 opened 3 years ago
Hi @ytx21cn . Thanks for reporting this. I'm able to reproduce the same issue in VS (where I can configure for Linux GCC, using Open Folder, a CppProperties.json
file, and setting intelliSenseMode to linux-gcc-x64
). I will open an issue against VS internally. (The IntelliSense implementation is shared between VS and the C/C++ extension for VS Code).
Hi @ytx21cn . Thanks for reporting this. I'm able to reproduce the same issue in VS (where I can configure for Linux GCC, using Open Folder, a
CppProperties.json
file, and setting intelliSenseMode tolinux-gcc-x64
). I will open an issue against VS internally. (The IntelliSense implementation is shared between VS and the C/C++ extension for VS Code).
It doesn't look like it is a settings-dependent issue. When I place a single .cpp file to somewhere that any project would almost never live there (such as ~/Desktop), I observe the same result. Hence it is the fault of internal VS calculations that yield the wrong results.
I see this when the structure in question has internal padding. For example:
struct test {
unsigned short a;
unsigned short b;
unsigned short c;
unsigned int d;
unsigned int e;
};
With alignment 4 VScode v 1.77.3 shows the sizeof (struct test)
to be 6, but at runtime it is 16. Arrays containing this structure are also shown incorrectly as a result.
This is internal bug 1418475.
It is not fixed as of VScode 1.93.1, C/C++ IntelliSense v1.22.7 (pre-release).
enum rx_desc_len {
RX_DESC_LEN_TYPE_1 = (sizeof(struct RxDesc)),
RX_DESC_LEN_TYPE_3 = (sizeof(struct RxDescV3)),
RX_DESC_LEN_TYPE_4 = (sizeof(struct RxDescV4))
};
All 3 sizes are wrong, the first two even come back as size 0. {
Bug type: Language Service
Describe the bug
Steps to reproduce
Code sample 1
Expected behavior
sizeof(test1)
gives 4 when the program runs. (when memory alignment is set to 4 bytes)Code sample 2
This time I add
#pragma pack(1)
.Expected behavior
sizeof(test1)
gives 3 when the program runs. (when memory alignment is set to 1 byte)