Skip to content

Commit 1a7369a

Browse files
aykevldeadprogram
authored andcommitted
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.
1 parent 928a970 commit 1a7369a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/runtime/slice.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ func sliceAppend(srcBuf, elemsBuf unsafe.Pointer, srcLen, srcCap, elemsLen uintp
4242
}
4343

4444
// Builtin copy(dst, src) function: copy bytes from dst to src.
45-
func sliceCopy(dst, src unsafe.Pointer, dstLen, srcLen uintptr, elemSize uintptr) uintptr {
45+
func sliceCopy(dst, src unsafe.Pointer, dstLen, srcLen uintptr, elemSize uintptr) int {
4646
// n = min(srcLen, dstLen)
4747
n := srcLen
4848
if n > dstLen {
4949
n = dstLen
5050
}
5151
memmove(dst, src, n*elemSize)
52-
return n
52+
return int(n)
5353
}

0 commit comments

Comments
 (0)