mirror of
https://github.com/ziglang/zig.git
synced 2025-12-30 10:03:21 +00:00
Fix abi size of optional slices
Previously, optional slices returned the pointer size as abi size. We now account for slices to calculate the correct size which is abi-alignment + slice ABI size.
This commit is contained in:
parent
eb70f6e8d7
commit
f763000dc9
@ -2157,7 +2157,7 @@ pub const Type = extern union {
|
||||
const child_type = self.optionalChild(&buf);
|
||||
if (!child_type.hasCodeGenBits()) return 1;
|
||||
|
||||
if (child_type.zigTypeTag() == .Pointer and !child_type.isCPtr())
|
||||
if (child_type.zigTypeTag() == .Pointer and !child_type.isCPtr() and !child_type.isSlice())
|
||||
return @divExact(target.cpu.arch.ptrBitWidth(), 8);
|
||||
|
||||
// Optional types are represented as a struct with the child type as the first
|
||||
@ -2344,7 +2344,7 @@ pub const Type = extern union {
|
||||
const child_type = ty.optionalChild(&buf);
|
||||
if (!child_type.hasCodeGenBits()) return 8;
|
||||
|
||||
if (child_type.zigTypeTag() == .Pointer and !child_type.isCPtr())
|
||||
if (child_type.zigTypeTag() == .Pointer and !child_type.isCPtr() and !child_type.isSlice())
|
||||
return target.cpu.arch.ptrBitWidth();
|
||||
|
||||
// Optional types are represented as a struct with the child type as the first
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user