diff options
| author | Mattias Andrée <m@maandree.se> | 2026-05-17 14:28:21 +0200 |
|---|---|---|
| committer | Mattias Andrée <m@maandree.se> | 2026-05-17 15:06:44 +0200 |
| commit | c77deb9313ee3c4ca9885191f5cb8e07d8d68ad3 (patch) | |
| tree | 1de53628d7bffdac84992d8ae1e36d4bf0265c90 /libj2_ji_sub_ji_to_j2i.c | |
| parent | Fix usage of va_arg (diff) | |
| download | libj2-c77deb9313ee3c4ca9885191f5cb8e07d8d68ad3.tar.gz libj2-c77deb9313ee3c4ca9885191f5cb8e07d8d68ad3.tar.bz2 libj2-c77deb9313ee3c4ca9885191f5cb8e07d8d68ad3.tar.xz | |
Fix undefined behaviour
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'libj2_ji_sub_ji_to_j2i.c')
| -rw-r--r-- | libj2_ji_sub_ji_to_j2i.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/libj2_ji_sub_ji_to_j2i.c b/libj2_ji_sub_ji_to_j2i.c index 1057db6..8bc5944 100644 --- a/libj2_ji_sub_ji_to_j2i.c +++ b/libj2_ji_sub_ji_to_j2i.c @@ -25,7 +25,7 @@ check(uintmax_t ua, uintmax_t ub) intmax_t a = ua >> (LIBJ2_JU_BIT - 1U) ? -(intmax_t)~ua - 1 : (intmax_t)ua; intmax_t b = ub >> (LIBJ2_JU_BIT - 1U) ? -(intmax_t)~ub - 1 : (intmax_t)ub; struct libj2_j2i r, expected; - struct libj2_j2u wa, wb; + struct libj2_j2u wa, wb, ue; #if INTMAX_MIN + 1 != -INTMAX_MAX if (ua == (UINTMAX >> 1) + 1U || ub == (UINTMAX >> 1) + 1U) @@ -39,7 +39,8 @@ check(uintmax_t ua, uintmax_t ub) wb.high = b < 0 ? UINTMAX_MAX : 0; libj2_minus_j2u(&wb); - libj2_j2u_add_j2u_to_j2u(&wa, &wb, (void *)&expected); + libj2_j2u_add_j2u_to_j2u(&wa, &wb, &ue); + libj2_j2u_to_j2i(&ue, &expected); libj2_ji_sub_ji_to_j2i(a, b, &r); EXPECT(libj2_j2i_eq_j2i(&r, &expected)); } |
