| ... | ... | @@ -1707,7 +1707,6 @@ static LLVMValueRef gen_widen_or_shorten(CodeGen *g, bool want_runtime_safety, Z |
| 1707 | 1707 | ZigType *wanted_type, LLVMValueRef expr_val) |
| 1708 | 1708 | { |
| 1709 | 1709 | assert(actual_type->id == wanted_type->id); |
| 1710 | | assert(expr_val != nullptr); |
| 1711 | 1710 | |
| 1712 | 1711 | ZigType *scalar_actual_type = (actual_type->id == ZigTypeIdVector) ? |
| 1713 | 1712 | actual_type->data.vector.elem_type : actual_type; |
| ... | ... | @@ -1733,6 +1732,19 @@ static LLVMValueRef gen_widen_or_shorten(CodeGen *g, bool want_runtime_safety, Z |
| 1733 | 1732 | zig_unreachable(); |
| 1734 | 1733 | } |
| 1735 | 1734 | |
| 1735 | if (expr_val == nullptr) { |
| 1736 | if (scalar_actual_type->id == ZigTypeIdInt && actual_bits == 0) { |
| 1737 | if (wanted_bits == 0) { |
| 1738 | return expr_val; |
| 1739 | } else { |
| 1740 | LLVMValueRef zero = LLVMConstNull(get_llvm_type(g, wanted_type)); |
| 1741 | return zero; |
| 1742 | } |
| 1743 | } else { |
| 1744 | zig_unreachable(); |
| 1745 | } |
| 1746 | } |
| 1747 | |
| 1736 | 1748 | if (scalar_actual_type->id == ZigTypeIdInt && want_runtime_safety && ( |
| 1737 | 1749 | // negative to unsigned |
| 1738 | 1750 | (!scalar_wanted_type->data.integral.is_signed && scalar_actual_type->data.integral.is_signed) || |