diff --git a/src/llvm_backend_expr.cpp b/src/llvm_backend_expr.cpp index 2ef7f9b29..63c45711f 100644 --- a/src/llvm_backend_expr.cpp +++ b/src/llvm_backend_expr.cpp @@ -2546,7 +2546,9 @@ gb_internal lbValue lb_emit_conv(lbProcedure *p, lbValue value, Type *t) { lbValue res_i128 = lb_emit_runtime_call(p, call, args); return lb_emit_conv(p, res_i128, t); } - i64 sz = type_size_of(src); + // the intermediate int must be at least as wide as the dest, + // otherwise e.g. f32 -> u64 truncates through a 32-bit fptoui + i64 sz = gb_max(type_size_of(src), type_size_of(dst)); lbValue res = {}; res.type = t;