Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fmt: Regression in fmt.Printf("%d", Error) where Error is an integer type satisfying error #30472

Closed
ncw opened this issue Feb 28, 2019 · 3 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Milestone

Comments

@ncw
Copy link
Contributor

ncw commented Feb 28, 2019

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

$ go version
go version devel +c2b707bcf1 Thu Feb 28 11:24:52 2019 +0000 linux/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/ncw/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/ncw/go"
GOPROXY=""
GORACE=""
GOROOT="/opt/go/go1.12"
GOTMPDIR=""
GOTOOLDIR="/opt/go/go1.12/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build543488653=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Compile and run this program

package main

import (
	"fmt"
)

type Error byte

func (e Error) Error() string {
	return fmt.Sprintf("Error number %d", e)
}

func main() {
	fmt.Printf("Error %d\n", Error(99))
}

What did you expect to see?

$ go version
go version go1.12 linux/amd64
$ go run err-bug.go
Error 99

What did you see instead?

$ go version
go version devel +c2b707bcf1 Thu Feb 28 11:24:52 2019 +0000 linux/amd64
$ go run err-bug.go
Error %!d(main.Error=99)

I used git-bisect to discover that it is caused by 6be6f11 on CL https://go-review.googlesource.com/c/go/+/163559 from #29934

I'm not sure if this is intended?

Cc: @mpvl

@bcmills bcmills added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 28, 2019
@bcmills bcmills added this to the Go1.13 milestone Feb 28, 2019
@bradfitz
Copy link
Contributor

This also broke x/net/idna's tests.

I sent off https://go-review.googlesource.com/c/net/+/164518 but it's a hacky workaround.

@neild
Copy link
Contributor

neild commented Feb 28, 2019

I've got a fix, will send it off when I finish testing it.

@gopherbot
Copy link

Change https://golang.org/cl/164557 mentions this issue: fmt: fix %d et al. on errors

@golang golang locked and limited conversation to collaborators Feb 28, 2020
@rsc rsc unassigned mpvl Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Projects
None yet
Development

No branches or pull requests

6 participants