On Wed, Jul 30, 2025 at 10:16:06AM +0200, Jakub Jelinek wrote: > Or maybe better > _BitInt(PROMOTED_SIZE (x) * __CHAR_BIT__) __x; > int __y = S (x); > do_copy (&__x, &(x), sizeof (__x)); > if (__y < PROMOTED_SIZE (x) * __CHAR_BIT__) > { > int __neg = __x < 0; > __x >>= PROMOTED_SIZE (x) * __CHAR_BIT__ - __y;
Obviously __x >>= __y; We want to shift away all the normal bits and keep just the padding bits which aren't padding in the promoted type. > if (__x != (__neg ? (typeof (__x)) -1 : (__typeof (__x)) 0)) > __builtin_abort (); > } > and just no __neg and if (__x) in the unsigned case? > The intent is not to invoke any UB, just have the memcpy hidden > from the optimizers. Jakub