mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
Sema: do not create slices with undefined pointers
The undef pointer ended up being zero on wasm32.
This commit is contained in:
parent
3b2c421102
commit
fc066992d9
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user