Skip to content

Fix #14474: Bad varid for global variable matching function pointer argument#8467

Open
ludviggunne wants to merge 3 commits intocppcheck-opensource:mainfrom
ludviggunne:14474
Open

Fix #14474: Bad varid for global variable matching function pointer argument#8467
ludviggunne wants to merge 3 commits intocppcheck-opensource:mainfrom
ludviggunne:14474

Conversation

@ludviggunne
Copy link
Copy Markdown
Collaborator

@ludviggunne ludviggunne commented Apr 20, 2026

This makes it so that varids for function pointer parameters are not set at all, AFAIK they can't be referred to anywhere else anyway. An alternative would be to always give it a unique varid, for the same reason.

@sonarqubecloud
Copy link
Copy Markdown

Comment thread test/testvarid.cpp

const char code3[] = "extern void (*arr[10])(uint32_t some);\n";
const char expected3[] = "1: extern void ( * arr@1 [ 10 ] ) ( uint32_t some@2 ) ;\n";
const char expected3[] = "1: extern void ( * arr@1 [ 10 ] ) ( uint32_t some ) ;\n";
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not against that no varid is set but it's not clear here in the test why there shouldn't be a varid. We could add a varid tomorrow and feel satisfied that it works properly.

I think the example code in 14474 should be added. Either we should set no varid or we should set a unique varid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants