zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit f0fdaf32d3b802e9db16a0753d9ff49a8667089b (tree)
parent 67afd2a470153681d3a2323ec388e3ecd545cef1
Author: Veikka Tuominen <git@vexu.eu>
Date:   Wed, 10 May 2023 16:26:54 +0300

fix incorrect use of mutable pointers to temporary values

Diffstat:
Mlib/std/os/linux/x86.zig | 2+-
Msrc/Module.zig | 2+-
Msrc/link/MachO/Atom.zig | 2+-
Mtest/behavior/array.zig | 2+-
4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/std/os/linux/x86.zig b/lib/std/os/linux/x86.zig @@ -108,7 +108,7 @@ pub fn syscall6( ); } -pub fn socketcall(call: usize, args: [*]usize) usize { +pub fn socketcall(call: usize, args: [*]const usize) usize { return asm volatile ("int $0x80" : [ret] "={eax}" (-> usize), : [number] "{eax}" (@enumToInt(SYS.socketcall)), diff --git a/src/Module.zig b/src/Module.zig @@ -6098,7 +6098,7 @@ pub const PeerTypeCandidateSrc = union(enum) { none: void, /// When we want to know the the src of candidate i, look up at /// index i in this slice - override: []?LazySrcLoc, + override: []const ?LazySrcLoc, /// resolvePeerTypes originates from a @TypeOf(...) call typeof_builtin_call_node_offset: i32, diff --git a/src/link/MachO/Atom.zig b/src/link/MachO/Atom.zig @@ -116,7 +116,7 @@ pub fn addRelocation(macho_file: *MachO, atom_index: Index, reloc: Relocation) ! return addRelocations(macho_file, atom_index, &[_]Relocation{reloc}); } -pub fn addRelocations(macho_file: *MachO, atom_index: Index, relocs: []Relocation) !void { +pub fn addRelocations(macho_file: *MachO, atom_index: Index, relocs: []const Relocation) !void { const gpa = macho_file.base.allocator; const gop = try macho_file.relocs.getOrPut(gpa, atom_index); if (!gop.found_existing) { diff --git a/test/behavior/array.zig b/test/behavior/array.zig @@ -667,7 +667,7 @@ test "array init of container level array variable" { test "runtime initialized sentinel-terminated array literal" { var c: u16 = 300; const f = &[_:0x9999]u16{c}; - const g = @ptrCast(*[4]u8, f); + const g = @ptrCast(*const [4]u8, f); try std.testing.expect(g[2] == 0x99); try std.testing.expect(g[3] == 0x99); }