Skip to content

Variadic func changes []byte(s) cap #24972

Closed
@inancgumus

Description

@inancgumus

What version of Go are you using (go version)?

Go 1.10.1

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

darwin/amd64

What did you do?

When you call a variadic func with a byte slice, calling cap is creating different results.

x := []byte("a")
    
// without this, Println prints 32 32
func(a ...[]byte) {}(x)
	
fmt.Println(cap(x), cap([]byte("a"))) // 8 32

https://play.golang.org/p/ZcrsUNAbPZr

What did you expect to see?

32 32

What did you see instead?

8 32

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions