Skip to content

Commit 8df29d1

Browse files
practicalswiftrustyrussell
authored andcommitted
The overflow check mul_overflows_s64(int64_t, int64_t) overflows and triggers UB :-) Remove it
The overflow check `mul_overflows_s64(int64_t, int64_t)` overflows. Since this is an signed integer overflow this triggers UB, which in turn means that we cannot trust the check. Luckily mul_overflows_s64(int64_t, int64_t) is unused. Removing it.
1 parent f2e81fd commit 8df29d1

File tree

1 file changed

+0
-10
lines changed

1 file changed

+0
-10
lines changed

common/overflows.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,6 @@ static inline bool add_overflows_u64(uint64_t a, uint64_t b)
1212
return (a + b) < a;
1313
}
1414

15-
static inline bool mul_overflows_s64(int64_t a, int64_t b)
16-
{
17-
int64_t ret;
18-
19-
if (a == 0)
20-
return false;
21-
ret = a * b;
22-
return (ret / a != b);
23-
}
24-
2515
static inline bool mul_overflows_u64(uint64_t a, uint64_t b)
2616
{
2717
uint64_t ret;

0 commit comments

Comments
 (0)