`TRANSMUTE()`: Fix input type size not being properly checked.

Fortune for naka's current commit: Curse − 凶
master
Avril 3 years ago
parent f0b9d00705
commit 612f0fe02a
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -209,6 +209,7 @@ static_assert_eq(bswap(bswap(128lu)), 128, "bswap128 (lu) failed (3)");
// Transmute // Transmute
#define TRANSMUTE(val, type) ({ union _trans { var(val) input; type output; }; \ #define TRANSMUTE(val, type) ({ union _trans { var(val) input; type output; }; \
_Static_assert(sizeof(var(val)) == sizeof(type), "Cannot transmute values of different sizes"); \
_Static_assert(sizeof(union _trans) == sizeof(type), "Cannot transmute values of different sizes"); \ _Static_assert(sizeof(union _trans) == sizeof(type), "Cannot transmute values of different sizes"); \
/* XXX: Do we need do check this for equality? Can we re-word it or do we even need it at all? _Static_assert(_Alignof(union _trans) == _Alignof(type), "Cannot transmute values of different alignments");*/ \ /* XXX: Do we need do check this for equality? Can we re-word it or do we even need it at all? _Static_assert(_Alignof(union _trans) == _Alignof(type), "Cannot transmute values of different alignments");*/ \
union _trans _trans__value = { .input = (val), }; \ union _trans _trans__value = { .input = (val), }; \

Loading…
Cancel
Save