[qfcc] Quieten ubsan

0-length arrays certainly would be UB if I tried using them, but I guess
ubsan isn't smart enough for that.
This commit is contained in:
Bill Currie 2025-01-21 11:09:00 +09:00
parent 74f973cddc
commit 809cffa3a8
2 changed files with 6 additions and 3 deletions

View file

@ -761,11 +761,14 @@ proc_decl (const expr_t *expr, rua_ctx_t *ctx)
if (decl_spec.type && decl_spec.type_expr) {
internal_error (0, "both type and type_expr set");
}
int count = list_count (&expr->decl.list);
if (!count) {
return block;
}
if (decl_spec.storage == sc_local) {
scoped_src_loc (expr);
block = new_block_expr (nullptr);
}
int count = list_count (&expr->decl.list);
const expr_t *decls[count];
list_scatter (&expr->decl.list, decls);
for (int i = 0; i < count; i++) {

View file

@ -1032,7 +1032,7 @@ find_function (const expr_t *fexpr, const expr_t *params, rua_ctx_t *ctx)
list_scatter_rev (&params->list, args);
}
callparm_t call_params[num_params] = {};
callparm_t call_params[num_params + 1] = {};
for (int i = 0; i < num_params; i++) {
auto e = args[i];
if (e->type == ex_error) {
@ -1083,7 +1083,7 @@ find_function (const expr_t *fexpr, const expr_t *params, rua_ctx_t *ctx)
}
}
unsigned costs[num_funcs] = {};
unsigned costs[num_funcs + 1] = {};
for (int i = 0; i < num_funcs; i++) {
auto f = (metafunc_t *) funcs[i];
int num_params = f->type->func.num_params;