On Fri, Jul 25, 2025 at 10:53:39AM +0800, Yang Yujie wrote: > In BEXTC, whether a _BitInt object is properly extended is examined > by a value comparison against a copied object in a wider _BitInt > type that utilizes all of the partial limb. > > Since the (implicit) conversion to the wider type may be optimized > away and cause the result of the comparison to always be true, > we need to cast the copied object down to the original type to > force a extension, so that it can serve as our reference. > > gcc/testsuite/ChangeLog: > > * gcc.dg/bitintext.h (BEXTC): Convert the copied object back > to the original type before comparison.
This makes no sense at all, you're not testing anything then. typeof (x) is the narrower type (smaller N). The lower bits will be always equal. The point was to test the padding bits. So, if the earlier patch optimizes away the extension, then you should just use volatile. So say _BitInt(PROMOTED_SIZE (x) * __CHAR_BIT__) __x; volatile __typeof_unqual__ (x) __y = (x); do_copy (&__x, &__y, sizeof (__x)); if (__x != __y) __builtin_abort (); etc. Jakub