Commit f0fdaf32d3

Veikka Tuominen <git@vexu.eu>
2023-05-10 15:26:54
fix incorrect use of mutable pointers to temporary values
1 parent 67afd2a
Changed files (4)
lib
std
os
linux
src
test
behavior
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)),
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) {
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,
 
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);
 }