| ... | @@ -17272,6 +17272,15 @@ fn zirPtrCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -17272,6 +17272,15 @@ fn zirPtrCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 17272 | else | 17272 | else |
| 17273 | operand; | 17273 | operand; |
| 17274 | | 17274 | |
| | 17275 | if (try sema.resolveMaybeUndefVal(block, operand_src, operand)) |operand_val| { |
| | 17276 | if (!dest_ty.ptrAllowsZero() and operand_val.isUndef()) { |
| | 17277 | return sema.failWithUseOfUndef(block, operand_src); |
| | 17278 | } |
| | 17279 | if (!dest_ty.ptrAllowsZero() and operand_val.isNull()) { |
| | 17280 | return sema.fail(block, operand_src, "null pointer casted to type {}", .{dest_ty.fmt(sema.mod)}); |
| | 17281 | } |
| | 17282 | } |
| | 17283 | |
| 17275 | const dest_elem_ty = dest_ty.elemType2(); | 17284 | const dest_elem_ty = dest_ty.elemType2(); |
| 17276 | try sema.resolveTypeLayout(block, dest_ty_src, dest_elem_ty); | 17285 | try sema.resolveTypeLayout(block, dest_ty_src, dest_elem_ty); |
| 17277 | const dest_align = dest_ty.ptrAlignment(target); | 17286 | const dest_align = dest_ty.ptrAlignment(target); |