Bug 24414 – ImportC: undefined identifier `__builtin_clz`

Status
NEW
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-02-26T09:43:11Z
Last change time
2024-12-13T19:33:30Z
Assigned to
No Owner
Creator
Richard (Rikki) Andrew Cattermole
Moved to GitHub: dmd#18216 →

Comments

Comment #0 by alphaglosined — 2024-02-26T09:43:11Z
Another ImportC intrinsic that is missing ``__builtin_clz``. From the NewsGroup comment: https://forum.dlang.org/post/[email protected]
Comment #1 by abryanbugzilla — 2024-02-26T16:09:32Z
I've ran into this issue before and worked around it by putting this in a D file: module util; // for C files built with import C that try to use GCC/clang builtin that importC does not provide extern(C) int __builtin_clz(int v) { return clz(v); } // count leading zeros. int clz(uint v) pure nothrow @nogc @safe in(v != 0) { import core.bitop : bsr; return 31 - bsr(v); } and putting __import util at the top of the C file
Comment #2 by robert.schadek — 2024-12-13T19:33:30Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18216 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB