aboutsummaryrefslogtreecommitdiff
path: root/src/analyze.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-09-16 11:23:38 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-09-16 11:23:38 -0400
commitdd5b2d1b04197903489f5da9c178e17e61bb55e3 (patch)
tree4c0e4cfd9774163cb0412e8f0b8edb7dc5756dfd /src/analyze.cpp
parent780e5674467ebac4534cd3d3f2199ccaf1d0922c (diff)
downloadzig-dd5b2d1b04197903489f5da9c178e17e61bb55e3.tar.gz
zig-dd5b2d1b04197903489f5da9c178e17e61bb55e3.zip
fix crash when pointer casting a runtime extern function
Diffstat (limited to 'src/analyze.cpp')
-rw-r--r--src/analyze.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp
index c9ae865390..0401c7125f 100644
--- a/src/analyze.cpp
+++ b/src/analyze.cpp
@@ -3992,9 +3992,10 @@ uint32_t get_ptr_align(CodeGen *g, ZigType *type) {
return (ptr_type->data.pointer.explicit_alignment == 0) ?
get_abi_alignment(g, ptr_type->data.pointer.child_type) : ptr_type->data.pointer.explicit_alignment;
} else if (ptr_type->id == ZigTypeIdFn) {
- return (ptr_type->data.fn.fn_type_id.alignment == 0) ?
- LLVMABIAlignmentOfType(g->target_data_ref, ptr_type->data.fn.raw_type_ref) :
- ptr_type->data.fn.fn_type_id.alignment;
+ // I tried making this use LLVMABIAlignmentOfType but it trips this assertion in LLVM:
+ // "Cannot getTypeInfo() on a type that is unsized!"
+ // when getting the alignment of `?extern fn() void`.
+ return (ptr_type->data.fn.fn_type_id.alignment == 0) ? 1 : ptr_type->data.fn.fn_type_id.alignment;
} else if (ptr_type->id == ZigTypeIdPromise) {
return get_coro_frame_align_bytes(g);
} else {