traefik / yaegi

Yaegi is Another Elegant Go Interpreter
https://pkg.go.dev/github.com/traefik/yaegi
Apache License 2.0
6.82k stars 342 forks source link

'cap' gives different results on 32-bit and 64-bit #1575

Open nileshpatra opened 1 year ago

nileshpatra commented 1 year ago

The following program sample.go triggers an unexpected result

package main

import "fmt"

func main() {
        a := []int{}
        a = append(a, 1)
        b := []int{}
        b = append(a, 2, 3)
        fmt.Println(cap(a))
        fmt.Println(cap(b))
        fmt.Println(b)
}

Expected result

### On 64 bit

1
3
[1 2 3]

Got

### On 32 bit

2
4
[1 2 3]

Yaegi Version

0.15.1

Additional Notes

On compiling with Go as GOARCH set to 386, the output matches on what I get with yaegi on 32-bit.

$ GOARCH=386 go run sample.go
2
4
[1 2 3]

Since runtime behavior on 32-bit is same, there are two question: