Skip to content

gnu.cfg: Add __builtin_ctz - #8721

Closed
kronus-ed wants to merge 1 commit into
cppcheck-opensource:mainfrom
kronus-ed:gnu-cfg-builtin-ctz
Closed

gnu.cfg: Add __builtin_ctz#8721
kronus-ed wants to merge 1 commit into
cppcheck-opensource:mainfrom
kronus-ed:gnu-cfg-builtin-ctz

Conversation

@kronus-ed

Copy link
Copy Markdown

__builtin_ctzl, and __builtin_ctzll trailing zero count functions.
@chrchr-github

Copy link
Copy Markdown
Collaborator

Thanks for your contribution. Can those functions be pure?

@aadanen

aadanen commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

I don't see __builtin_ctz at that link. I instead found it here: https://gcc.gnu.org/onlinedocs/gcc/Bit-Operation-Builtins.html, which has several other similar functions that could be added as well. I also found a file in gcc that gives the ctz builtin ATTR_CONST_NOTHROW_LEAF_LIST so it is pure/const as expected of a bit fiddling function. I will look into making a more general PR for all these builtins.

chrchr-github pushed a commit that referenced this pull request Sep 10, 2026
I implemented all of the functions described at
[https://gcc.gnu.org/onlinedocs/gcc/Built-in-Functions.html](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 <function> tag? I have
some tests, but I figured I would ask first.
@chrchr-github

Copy link
Copy Markdown
Collaborator

Superseded by #8843

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.

3 participants