From e02e4532659a69ef1871caf487432c6da9678a41 Mon Sep 17 00:00:00 2001 From: Yichao Yu Date: Wed, 29 Oct 2025 17:29:05 -0400 Subject: [PATCH] Remove useless size check in Memory allocation --- src/codegen.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/codegen.cpp b/src/codegen.cpp index b8e1061728127..8918d4435457e 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -4137,9 +4137,9 @@ static bool emit_builtin_call(jl_codectx_t &ctx, jl_cgval_t *ret, jl_value_t *f, if (argv[2].constant) { if (!jl_is_long(argv[2].constant)) return false; - size_t nel = jl_unbox_long(argv[2].constant); - if (nel < 0) - return false; + // Cast to a unsigned size and let `emit_const_len_memorynew` + // make sure that `nel` fits in a positive signed integer. + size_t nel = (size_t)jl_unbox_long(argv[2].constant); *ret = emit_const_len_memorynew(ctx, typ, nel, inst); } else {