Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc fixes #14333

Merged
merged 10 commits into from
Jan 18, 2023
Prev Previous commit
Next Next commit
Sema: do not create slices with undefined pointers
The undef pointer ended up being zero on wasm32.
  • Loading branch information
Vexu committed Jan 17, 2023
commit fc066992d912186da08ac9250b3772103aafbbe8
7 changes: 6 additions & 1 deletion src/Sema.zig
Original file line number Diff line number Diff line change
@@ -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);