[Bug tree-optimization/119186] Using __builtin_ctz results in a error result.

2025-03-10 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119186

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #5 from Jakub Jelinek  ---
In __builtin_ctzg(mask, 16); form (or whatever other value you want in case of
mask being 0).  __builtin_ctzg(mask) still has UB when mask is 0.

[Bug tree-optimization/119186] Using __builtin_ctz results in a error result.

2025-03-10 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119186

--- Comment #4 from Jonathan Wakely  ---
With GCC 15 you can use __builtin_ctzg which can accept zero.

Or just use std::count_rzero instead.

[Bug tree-optimization/119186] Using __builtin_ctz results in a error result.

2025-03-10 Thread drfeng08 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119186

--- Comment #3 from hao an  ---
thanks

[Bug tree-optimization/119186] Using __builtin_ctz results in a error result.

2025-03-10 Thread xry111 at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119186

Xi Ruoyao  changed:

   What|Removed |Added

 CC||xry111 at gcc dot gnu.org
 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |INVALID

--- Comment #1 from Xi Ruoyao  ---
With -fsanitize=undefined:

t.c:13:30: runtime error: passing zero to ctz(), which is not a valid argument

Quote from the GCC manual:

 -- Built-in Function: int __builtin_ctz (unsigned int X)
 Returns the number of trailing 0-bits in X, starting at the least
 significant bit position.  If X is 0, the result is undefined.

[Bug tree-optimization/119186] Using __builtin_ctz results in a error result.

2025-03-10 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119186

--- Comment #2 from Andrew Pinski  ---
__builtin_ctz with a value of 0 is undefined..