Browse Source

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

Fortune for naka's current commit: Curse − 凶
master
Avril 4 months ago
parent
commit
612f0fe02a
Signed by: flanchan GPG Key ID: 284488987C31F630
  1. 1
      include/macros.h

1
include/macros.h

@ -209,6 +209,7 @@ static_assert_eq(bswap(bswap(128lu)), 128, "bswap128 (lu) failed (3)");
// Transmute
#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"); \
/* 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), }; \

Loading…
Cancel
Save