Skip to content

cmd/compile: os.Stdout.Write causes its argument to escape on Windows #57740

@ALTree

Description

@ALTree
go version go1.19.5 linux/amd64
go version devel go1.20-76d39ae349 Tue Jan 10 20:34:22 2023 +0000 linux/amd64
package p

import "os"

func f() {
	os.Stdout.Write([]byte{'h', 'e', 'l', 'l', 'o'})
}

Linux:

$ GOOS=linux gotip build -gcflags=-m test.go

./test.go:5:6: can inline f
./test.go:6:24: []byte{...} does not escape             <<<<

Windows:

$ GOOS=windows gotip build -gcflags=-m test.go

./test.go:5:6: can inline f
./test.go:6:24: []byte{...} escapes to heap             <<<<

Read is also affected.

Reproducible on tip and 1.19.5.

Related to #41474

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.OS-WindowsPerformancecompiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions