aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-09-25 12:03:39 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-09-25 12:03:39 -0400
commit2e562a5f366aabefd34a4191b2cd0b5e72d3d089 (patch)
tree96192ee77cac902e9954d534a5009c4c04e28855 /src/ir.cpp
parent839492d0e82e5d7b2a5cee54acb9e64b414e9817 (diff)
downloadzig-2e562a5f366aabefd34a4191b2cd0b5e72d3d089.tar.gz
zig-2e562a5f366aabefd34a4191b2cd0b5e72d3d089.zip
fix crash on runtime index into slice of comptime type
closes #1435
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index 95172e2b59..33d42cfc5f 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -14640,6 +14640,12 @@ static ZigType *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstructionEle
} else {
// runtime known element index
+ if (type_requires_comptime(return_type)) {
+ ir_add_error(ira, elem_index,
+ buf_sprintf("values of type '%s' must be comptime known, but index value is runtime known",
+ buf_ptr(&return_type->data.pointer.child_type->name)));
+ return ira->codegen->builtin_types.entry_invalid;
+ }
if (ptr_align < abi_align) {
if (elem_size >= ptr_align && elem_size % ptr_align == 0) {
return_type = adjust_ptr_align(ira->codegen, return_type, ptr_align);