Skip to content

Commit a9678e5

Browse files
committed
fix UB in fold.c
1 parent 4dc2cbf commit a9678e5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/shady/fold.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,11 @@ break;
172172
}
173173
case convert_op: {
174174
const Type* dst_t = first(payload.type_arguments);
175-
uint64_t bitmask = ~(UINT64_MAX << get_type_bitwidth(dst_t));
175+
uint64_t bitmask = 0;
176176
if (get_type_bitwidth(dst_t) == 64)
177177
bitmask = UINT64_MAX;
178+
else
179+
bitmask = ~(UINT64_MAX << get_type_bitwidth(dst_t));
178180
if (dst_t->tag == Int_TAG) {
179181
if (all_int_literals) {
180182
uint64_t old_value = get_int_literal_value(*int_literals[0], int_literals[0]->is_signed);

0 commit comments

Comments
 (0)