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.
---
 gcc/testsuite/gcc.dg/bitintext.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/bitintext.h b/gcc/testsuite/gcc.dg/bitintext.h
index 522b96ed715..f12591ae37d 100644
--- a/gcc/testsuite/gcc.dg/bitintext.h
+++ b/gcc/testsuite/gcc.dg/bitintext.h
@@ -31,14 +31,14 @@ do_copy (void *p, const void *q, __SIZE_TYPE__ r)
       {                                                                \
        _BitInt(PROMOTED_SIZE (x) * __CHAR_BIT__) __x;          \
        do_copy (&__x, &(x), sizeof (__x));                     \
-       if (__x != (x))                                         \
+       if ((typeof (x)) __x != (x))                            \
          __builtin_abort ();                                   \
       }                                                                \
     else                                                       \
       {                                                                \
        unsigned _BitInt(PROMOTED_SIZE (x) * __CHAR_BIT__) __x; \
        do_copy (&__x, &(x), sizeof (__x));                     \
-       if (__x != (x))                                         \
+       if ((typeof (x)) __x != (x))                            \
          __builtin_abort ();                                   \
       }                                                                \
   } while (0)
-- 
2.46.0

Reply via email to