Skip to content

cmd/compile: conflicting escape analysis result and benchmark result output messages #46908

@zigo101

Description

@zigo101

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

$ go version
go version go1.16.5 linux/amd64

Does this issue reproduce with the latest release?

Yes

What did you do?

package concat

import (
    "testing"
)

var s33 = []byte{32: 'b'}
var a = string(s33)


func Benchmark_e_33(b *testing.B) {
    for i := 0; i < b.N; i++ {
        _ = a + a // a + a does not escape
    }
}

What did you expect to see?

No allocations. Or says "a + a escapes to heap"

What did you see instead?

$ go test -gcflags=-m
..
./concat_test.go:13:15: a + a does not escape
..
$ go test -bench=. -benchmem 
...
Benchmark_e_33-4   	14399670	        75.39 ns/op	      80 B/op	       1 allocs/op

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