diff options
| author | Veikka Tuominen <git@vexu.eu> | 2023-01-17 20:06:41 +0200 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2023-01-17 20:28:43 +0200 |
| commit | fc066992d912186da08ac9250b3772103aafbbe8 (patch) | |
| tree | 3b48356f1ee0a2e43e59618eaa05abf9feb8cff9 /src/Sema.zig | |
| parent | 3b2c4211027c235e3bc38043be99fc5be5e870e1 (diff) | |
| download | zig-fc066992d912186da08ac9250b3772103aafbbe8.tar.gz zig-fc066992d912186da08ac9250b3772103aafbbe8.zip | |
Sema: do not create slices with undefined pointers
The undef pointer ended up being zero on wasm32.
Diffstat (limited to 'src/Sema.zig')
| -rw-r--r-- | src/Sema.zig | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index 943f0adf6b..dcc38e4c0a 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -24822,8 +24822,13 @@ fn coerceExtra( // empty tuple to zero-length slice // note that this allows coercing to a mutable slice. if (inst_child_ty.structFieldCount() == 0) { + // Optional slice is represented with a null pointer so + // we use a dummy pointer value with the required alignment. const slice_val = try Value.Tag.slice.create(sema.arena, .{ - .ptr = Value.undef, + .ptr = if (dest_info.@"align" != 0) + try Value.Tag.int_u64.create(sema.arena, dest_info.@"align") + else + try inst_child_ty.lazyAbiAlignment(target, sema.arena), .len = Value.zero, }); return sema.addConstant(dest_ty, slice_val); |
