Skip to content

Commit a1af7cb

Browse files
committed
report compile error instead of crashing for void in var args
See #557
1 parent 1758939 commit a1af7cb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/ir.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -10369,7 +10369,11 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
1036910369
arg_tuple_i < arg->value.data.x_arg_tuple.end_index; arg_tuple_i += 1)
1037010370
{
1037110371
VariableTableEntry *arg_var = get_fn_var_by_index(parent_fn_entry, arg_tuple_i);
10372-
assert(arg_var != nullptr);
10372+
if (arg_var == nullptr) {
10373+
ir_add_error(ira, arg,
10374+
buf_sprintf("compiler bug: var args can't handle void. https://github.com/zig-lang/zig/issues/557"));
10375+
return ira->codegen->builtin_types.entry_invalid;
10376+
}
1037310377
IrInstruction *arg_var_ptr_inst = ir_get_var_ptr(ira, arg, arg_var, true, false);
1037410378
if (type_is_invalid(arg_var_ptr_inst->value.type))
1037510379
return ira->codegen->builtin_types.entry_invalid;

0 commit comments

Comments
 (0)