[PATCH 2/2] stdlib: Fix stdbit.h with -Wconversion for clang

Joseph Myers jsm@polyomino.org.uk
Thu Jan 4 20:07:59 GMT 2024


On Thu, 4 Jan 2024, Adhemerval Zanella wrote:

> -# define stdc_trailing_zeros_uc(x) (__ctz8_inline (x))
> -# define stdc_trailing_zeros_us(x) (__ctz16_inline (x))
> +# define stdc_trailing_zeros_uc(x) (__ctz8_inline (__pacify_uint8 (x)))
> +# define stdc_trailing_zeros_us(x) (__ctz16_inline (__pacify_uint16 (x)))

For all of these cases, I think the __pacify calls should go in the 
type-generic macros, not the type-specific ones.  For the type-specific 
macros I think it's best to have the implicit conversions (to ensure the 
user gets the expected diagnostics for an implicit conversion if they've 
somehow passed a type for which an implicit conversion is invalid, e.g. a 
pointer type - an actual function call would have an implicit conversion, 
and the type-specific macros should have effects as similar as possible to 
a function call, which the current definitions achieve by directly calling 
an inline function).

-- 
Joseph S. Myers
jsm@polyomino.org.uk


More information about the Libc-alpha mailing list