From e37a629adc78772c87b8830448dc99eef0cdd91e Mon Sep 17 00:00:00 2001 From: Matthew Suozzo Date: Wed, 11 Nov 2026 00:22:34 +0000 Subject: [PATCH] Return signed int32/int64 from libc-gen strtoul/strtoull. Generated Wasm functions represent i32/i64 results as signed int32/int64, so unsigned return types on strtoul/strtoull fail Go type checking at call sites. --- libc-gen/go/stdlib.go | 8 ++++---- libc-gen/go/stdlib_test.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libc-gen/go/stdlib.go b/libc-gen/go/stdlib.go index c2c4a4af..e2402d69 100644 --- a/libc-gen/go/stdlib.go +++ b/libc-gen/go/stdlib.go @@ -21,16 +21,16 @@ func strtoll(s, endptr sptr_t, base int32) int64 { return strtoll_helper(s, endptr, base, 64) } -func strtoull(s, endptr sptr_t, base int32) uint64 { - return strtoull_helper(s, endptr, base, 64) +func strtoull(s, endptr sptr_t, base int32) int64 { + return int64(strtoull_helper(s, endptr, base, 64)) } func strtol(s, endptr sptr_t, base int32) int32 { return int32(strtoll_helper(s, endptr, base, 32)) } -func strtoul(s, endptr sptr_t, base int32) uint32 { - return uint32(strtoull_helper(s, endptr, base, 32)) +func strtoul(s, endptr sptr_t, base int32) int32 { + return int32(strtoull_helper(s, endptr, base, 32)) } func strtod_helper(s, endptr sptr_t, bitSize int) float64 { diff --git a/libc-gen/go/stdlib_test.go b/libc-gen/go/stdlib_test.go index 37054773..fc546b21 100644 --- a/libc-gen/go/stdlib_test.go +++ b/libc-gen/go/stdlib_test.go @@ -114,8 +114,8 @@ func Test_strtoul(t *testing.T) { store32(memory, cptr_t(endptr), 0) got := strtoul(start, endptr, tc.base) - if got != tc.want { - t.Fatalf("got %v, want %v", got, tc.want) + if uint32(got) != tc.want { + t.Fatalf("got %v, want %v", uint32(got), tc.want) } end := sptr_t(load32(memory, cptr_t(endptr)))