mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
codegen: Write padding bytes for unions
Previously we did not write any missing padding bytes after the smallest field (either tag or payload, depending on alignment). This resulted in writing too few bytes and not matching the full abisize of the union.
This commit is contained in:
parent
7e10cf4fbe
commit
ebfd3450d9
@ -1726,8 +1726,8 @@ fn isByRef(ty: Type, target: std.Target) bool {
|
||||
|
||||
.Array,
|
||||
.Frame,
|
||||
.Union,
|
||||
=> {
|
||||
=> return ty.hasRuntimeBitsIgnoreComptime(),
|
||||
.Union => {
|
||||
if (ty.castTag(.@"union")) |union_ty| {
|
||||
if (union_ty.data.layout == .Packed) {
|
||||
return ty.abiSize(target) > 8;
|
||||
|
||||
@ -611,6 +611,10 @@ pub fn generateSymbol(
|
||||
}
|
||||
}
|
||||
|
||||
if (layout.padding > 0) {
|
||||
try code.writer().writeByteNTimes(0, layout.padding);
|
||||
}
|
||||
|
||||
return Result.ok;
|
||||
},
|
||||
.Optional => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user