From 1a7369af6e3abc7f95f867d42ed037a3ebea9c0f Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Wed, 11 Mar 2020 16:34:40 +0100 Subject: [PATCH] runtime: return the correct type from the copy builtin The copy builtin is defined as follows by the Go language spec: copy(dst, src []T) int copy(dst []byte, src string) int In other words, it returns an int. The runtime.sliceCopy compiler intrinsic returned a uintptr instead, which led to a problem while compiling the strings package for AVR. No other architecture should be affected by this change as the conversion from an uintptr to an int is a no-op on most architectures. --- src/runtime/slice.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/runtime/slice.go b/src/runtime/slice.go index 3ea0fe44..923e30bd 100644 --- a/src/runtime/slice.go +++ b/src/runtime/slice.go @@ -42,12 +42,12 @@ func sliceAppend(srcBuf, elemsBuf unsafe.Pointer, srcLen, srcCap, elemsLen uintp } // Builtin copy(dst, src) function: copy bytes from dst to src. -func sliceCopy(dst, src unsafe.Pointer, dstLen, srcLen uintptr, elemSize uintptr) uintptr { +func sliceCopy(dst, src unsafe.Pointer, dstLen, srcLen uintptr, elemSize uintptr) int { // n = min(srcLen, dstLen) n := srcLen if n > dstLen { n = dstLen } memmove(dst, src, n*elemSize) - return n + return int(n) }