aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuuk de Gram <luuk@degram.dev>2022-01-20 19:44:28 +0100
committerAndrew Kelley <andrew@ziglang.org>2022-01-20 18:19:20 -0500
commitf763000dc918c2367ebc181645eb48db896205d8 (patch)
treee51b07e48ba4a0e1a138f9e9a9b42a3aa2a4a3b7 /src
parenteb70f6e8d7f4c1a735fe25de368f6d5459cba16c (diff)
downloadzig-f763000dc918c2367ebc181645eb48db896205d8.tar.gz
zig-f763000dc918c2367ebc181645eb48db896205d8.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/type.zig4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/type.zig b/src/type.zig
index f62c94c469..77ff171776 100644
--- a/src/type.zig
+++ b/src/type.zig
@@ -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