https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89670
--- Comment #12 from Jakub Jelinek <jakub at gcc dot gnu.org> --- (In reply to Jörn Engel from comment #11) > Out of curiosity, if the only non-broken way to call __builtin_ctz(foo) is > via "foo ? __builtin_ctz(foo) : 32", why isn't the conditional moved into > __builtin_ctz()? Is there some hidden advantage from callers having to add > the conditional or getting surprised by undefined behaviour? In many cases you know the argument is not zero, so no need to write it that way. Plus, not everybody wants value 32 for the case when the argument is 0. Some CPUs have instructions that return -1 in such cases, other return say 64 even when the ctz is 32-bit and it is up to the user to specify in the code what they want.