Skip to content

math/big: Subsequent calls to Rat.SetString set incorrect value #31184

@aclindsa

Description

@aclindsa

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

$ go version
go version devel +e4ba40030f Mon Mar 25 22:29:26 2019 +0000 linux/amd64

Does this issue reproduce with the latest release?

No, as far as I know, the issue is limited to the development branch and has not been released. I've bisected the issue to commit e4ba400.

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

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/me/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/me/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/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-build774704940=/tmp/go-build -gno-record-gcc-switches"

What did you do?

See https://play.golang.org/p/o3Oz63_fwGq (doesn't reproduce, because is using the released version) or add the following to src/math/big/rat_test.go with a current build from master:

func TestSubsequentSetStrings(t *testing.T) {
       a := new(Rat)
       a.SetString("-213.09")
       a.SetString("8.192")
       if a.FloatString(3) != "8.192" {
               t.Errorf("0) got %s want 8.192", a.FloatString(3))
       }
}

What did you expect to see?

8.192

What did you see instead?

1024.000

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions