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:
@@ -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 => {
|
||||
|
||||
Reference in New Issue
Block a user