Skip to content

gnu.cfg: Add all bit operation builtins - #8843

Merged
chrchr-github merged 4 commits into
cppcheck-opensource:mainfrom
aadanen:gnu_cfg_bit
Sep 10, 2026
Merged

gnu.cfg: Add all bit operation builtins#8843
chrchr-github merged 4 commits into
cppcheck-opensource:mainfrom
aadanen:gnu_cfg_bit

Conversation

@aadanen

@aadanen aadanen commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

I implemented all of the functions described at https://gcc.gnu.org/onlinedocs/gcc/Built-in-Functions.html except for the ones that have a variable return type based on the arguments. This PR should be a superset of the changes proposed in #8721.

I didn't write any tests because I am not sure what the standard practice is. Should I try to have a test for each tag? I have some tests, but I figured I would ask first.

@chrchr-github

Copy link
Copy Markdown
Collaborator

I didn't write any tests because I am not sure what the standard practice is. Should I try to have a test for each tag? I have some tests, but I figured I would ask first.

A few tests would be nice. The configuration looks pretty standard though, so no need to test every function.

@aadanen

aadanen commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

I think CI-unixish failed because it looks like __builtin_stdc_bit_width is only supported starting with gcc 14.1? https://snapshots.sourceware.org/glibc/trunk/latest/manual/html_node/Bit-Manipulation.html

It appears in the gcc changelog starting in 2023, but the machine uses ubuntu 22.04 which came out in 2022, so that older version of GCC throws an error when it tries to verify the syntax of that test.

we could:

  1. update the test runner
  2. not have a test for __builtin_stdc_bit_width
  3. not support __builtin_stdc_bit_width at all

@chrchr-github

Copy link
Copy Markdown
Collaborator

How about
4. check __GNUC__?

@chrchr-github
chrchr-github merged commit 982b140 into cppcheck-opensource:main Sep 10, 2026
71 checks passed
@aadanen
aadanen deleted the gnu_cfg_bit branch September 10, 2026 21:14
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