Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive error on C nested structs #13017

Open
rcls opened this issue Dec 4, 2024 · 1 comment
Open

False positive error on C nested structs #13017

rcls opened this issue Dec 4, 2024 · 1 comment
Labels
Milestone

Comments

@rcls
Copy link

rcls commented Dec 4, 2024

Type: Bug

VSCode claims that the assignment to foo.bar below is an error "a value of type "struct Bar" cannot be assigned to an entity of type "struct Bar" C/C++(513)"

The code compiles cleanly both with gcc and clang (with -Wall -Wextra in both cases). I believe it is ISO C compliant, although a fairly uncommon usage. (In C nested, named, structs become part of the global namespace, which is different from C++.)

// C not C++.
struct Foo {
    struct Bar {
        int x;
    } bar;
};

int main(void)
{
    struct Foo foo;
    foo.bar = (struct Bar) {0}; // Incorrectly marked as an error by VSCode.
    return foo.bar.x;
}

Extension version: 1.22.11
VS Code version: Code 1.95.3 (f1a4fb101478ce6ec82fe9627c43efbf9e98c813, 2024-11-13T14:50:04.152Z)
OS version: Linux x64 6.11.7-300.fc41.x86_64
Modes:

System Info
Item Value
CPUs Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz (8 x 3700)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
webnn: disabled_off
Load (avg) 1, 1, 1
Memory (System) 62.48GB (36.96GB free)
Process Argv --crash-reporter-id 73c5a75d-b680-4906-94d8-412f0182e453
Screen Reader no
VM 0%
DESKTOP_SESSION mate
XDG_CURRENT_DESKTOP MATE
XDG_SESSION_DESKTOP mate
XDG_SESSION_TYPE x11
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805:30301674
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
2i9eh265:30646982
962ge761:30959799
pythonnoceb:30805159
asynctok:30898717
pythonmypyd1:30879173
h48ei257:31000450
pythontbext0:30879054
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
dsvsc021:30996838
724cj586:31013169
dvdeprecation:31068756
dwnewjupytercf:31046870
2f103344:31071589
nativerepl2:31139839
pythonrstrctxt:31112756
cf971741:31144450
iacca1:31171482
notype1cf:31157160
5fd0e150:31155592
dwcopilot:31170013
stablechunks:31184530

@sean-mcmanus
Copy link
Contributor

@rcls I've filed a bug against our shared VS parser at https://developercommunity.visualstudio.com/t/C-IntelliSense-marks-certain-code-as-an/10809897 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

No branches or pull requests

2 participants