fix incorrect use of mutable pointers to temporary values

This commit is contained in:
Veikka Tuominen 2023-05-10 16:26:54 +03:00
parent 67afd2a470
commit f0fdaf32d3
4 changed files with 4 additions and 4 deletions

View File

@ -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)),

View File

@ -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,

View File

@ -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) {

View File

@ -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);
}