aboutsummaryrefslogtreecommitdiff
path: root/src/check_builtin.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2022-11-11 15:54:13 +0000
committergingerBill <bill@gingerbill.org>2022-11-11 15:54:13 +0000
commit3d0e19429818781882deca35df730b3766bade5d (patch)
tree6fbc39a22273d0c2df2f199f5ce9c7d1f3705eb6 /src/check_builtin.cpp
parentfcd8860990f2f389dd257e316f78c69b3d486aac (diff)
Check for non-zero sized elements for `intrinsics.ptr_sub`
Diffstat (limited to 'src/check_builtin.cpp')
-rw-r--r--src/check_builtin.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp
index b8bf1bcc7..eeadd8ef8 100644
--- a/src/check_builtin.cpp
+++ b/src/check_builtin.cpp
@@ -4182,6 +4182,13 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32
return false;
}
+ Type *elem = type_deref(ptr0.type);
+ if (type_size_of(elem) == 0) {
+ gbString str = type_to_string(ptr0.type);
+ error(ptr0.expr, "Expected a pointer to a non-zero sized element for '%.*s', got %s", LIT(builtin_name), str);
+ gb_string_free(str);
+ return false
+ }
}
break;