Skip to content

math/big: incorrect handling of aliased inputs in GCD #30217

@bmkessler

Description

@bmkessler

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

$ go version
go1.11.2 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

What did you do?

Calculate the cofactors x, y using the input variables (a, b) to store the result

d.GCD(x, y, a, b) --> x = 1, y = -1 (correct)
d.GCD(a, b, a, b) --> a = 1, b = 1 (incorrect)
d.GCD(b, a, a, b) --> b = 1, a = -6 (incorrect)

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

What did you expect to see?

Correct results that match when independent x, y are used.

What did you see instead?

Incorrect results when x and y reference the input variables a, b.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions