| ... | @@ -19626,7 +19626,7 @@ fn zirIntToPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -19626,7 +19626,7 @@ fn zirIntToPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 19626 | } | 19626 | } |
| 19627 | | 19627 | |
| 19628 | try sema.requireRuntimeBlock(block, src, operand_src); | 19628 | try sema.requireRuntimeBlock(block, src, operand_src); |
| 19629 | if (block.wantSafety() and try sema.typeHasRuntimeBits(elem_ty)) { | 19629 | if (block.wantSafety() and (try sema.typeHasRuntimeBits(elem_ty) or elem_ty.zigTypeTag() == .Fn)) { |
| 19630 | if (!ptr_ty.isAllowzeroPtr()) { | 19630 | if (!ptr_ty.isAllowzeroPtr()) { |
| 19631 | const is_non_zero = try block.addBinOp(.cmp_neq, operand_coerced, .zero_usize); | 19631 | const is_non_zero = try block.addBinOp(.cmp_neq, operand_coerced, .zero_usize); |
| 19632 | try sema.addSafetyCheck(block, is_non_zero, .cast_to_null); | 19632 | try sema.addSafetyCheck(block, is_non_zero, .cast_to_null); |
| ... | @@ -19852,7 +19852,7 @@ fn zirPtrCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -19852,7 +19852,7 @@ fn zirPtrCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 19852 | | 19852 | |
| 19853 | try sema.requireRuntimeBlock(block, src, null); | 19853 | try sema.requireRuntimeBlock(block, src, null); |
| 19854 | if (block.wantSafety() and operand_ty.ptrAllowsZero() and !dest_ty.ptrAllowsZero() and | 19854 | if (block.wantSafety() and operand_ty.ptrAllowsZero() and !dest_ty.ptrAllowsZero() and |
| 19855 | try sema.typeHasRuntimeBits(dest_ty.elemType2())) | 19855 | (try sema.typeHasRuntimeBits(dest_ty.elemType2()) or dest_ty.elemType2().zigTypeTag() == .Fn)) |
| 19856 | { | 19856 | { |
| 19857 | const ptr_int = try block.addUnOp(.ptrtoint, ptr); | 19857 | const ptr_int = try block.addUnOp(.ptrtoint, ptr); |
| 19858 | const is_non_zero = try block.addBinOp(.cmp_neq, ptr_int, .zero_usize); | 19858 | const is_non_zero = try block.addBinOp(.cmp_neq, ptr_int, .zero_usize); |
| ... | @@ -27718,7 +27718,7 @@ fn coerceCompatiblePtrs( | ... | @@ -27718,7 +27718,7 @@ fn coerceCompatiblePtrs( |
| 27718 | try sema.requireRuntimeBlock(block, inst_src, null); | 27718 | try sema.requireRuntimeBlock(block, inst_src, null); |
| 27719 | const inst_allows_zero = inst_ty.zigTypeTag() != .Pointer or inst_ty.ptrAllowsZero(); | 27719 | const inst_allows_zero = inst_ty.zigTypeTag() != .Pointer or inst_ty.ptrAllowsZero(); |
| 27720 | if (block.wantSafety() and inst_allows_zero and !dest_ty.ptrAllowsZero() and | 27720 | if (block.wantSafety() and inst_allows_zero and !dest_ty.ptrAllowsZero() and |
| 27721 | try sema.typeHasRuntimeBits(dest_ty.elemType2())) | 27721 | (try sema.typeHasRuntimeBits(dest_ty.elemType2()) or dest_ty.elemType2().zigTypeTag() == .Fn)) |
| 27722 | { | 27722 | { |
| 27723 | const actual_ptr = if (inst_ty.isSlice()) | 27723 | const actual_ptr = if (inst_ty.isSlice()) |
| 27724 | try sema.analyzeSlicePtr(block, inst_src, inst, inst_ty) | 27724 | try sema.analyzeSlicePtr(block, inst_src, inst, inst_ty) |