diff options
| author | LemonBoy <thatlemon@gmail.com> | 2019-12-20 10:48:03 +0100 |
|---|---|---|
| committer | LemonBoy <thatlemon@gmail.com> | 2020-01-08 20:03:03 +0100 |
| commit | e134e6c994d6ecd76dc6ae1a24b8de29c4147eab (patch) | |
| tree | 6c0b4e7a367fd0507d0f32e0de131a43d8b9e444 /lib/std | |
| parent | 02ace4569ec52561f627ad3a33d7b90b7bdbb6f5 (diff) | |
| download | zig-e134e6c994d6ecd76dc6ae1a24b8de29c4147eab.tar.gz zig-e134e6c994d6ecd76dc6ae1a24b8de29c4147eab.zip | |
Pointer arithmetic affects the alignment factor
Closes #1528
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/start.zig | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/std/start.zig b/lib/std/start.zig index 7c1353e18b..7a10d87300 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -142,14 +142,14 @@ fn posixCallMainAndExit() noreturn { const argc = starting_stack_ptr[0]; const argv = @ptrCast([*][*:0]u8, starting_stack_ptr + 1); - const envp_optional = @ptrCast([*:null]?[*:0]u8, argv + argc + 1); + const envp_optional = @ptrCast([*:null]?[*:0]u8, @alignCast(@alignOf(usize), argv + argc + 1)); var envp_count: usize = 0; while (envp_optional[envp_count]) |_| : (envp_count += 1) {} const envp = @ptrCast([*][*:0]u8, envp_optional)[0..envp_count]; if (builtin.os == .linux) { // Find the beginning of the auxiliary vector - const auxv = @ptrCast([*]std.elf.Auxv, envp.ptr + envp_count + 1); + const auxv = @ptrCast([*]std.elf.Auxv, @alignCast(@alignOf(usize), envp.ptr + envp_count + 1)); std.os.linux.elf_aux_maybe = auxv; // Initialize the TLS area const gnu_stack_phdr = std.os.linux.tls.initTLS() orelse @panic("ELF missing stack size"); |
