Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Bug in overflow multiplication of uint type. #652

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

Open
dmitshur opened this issue Jun 24, 2017 · 0 comments
Open

Bug in overflow multiplication of uint type. #652

dmitshur opened this issue Jun 24, 2017 · 0 comments

Comments

@dmitshur
Copy link
Member

This might affect int type too, I haven't verified.

It does not affect uintptr, nor uint32.

package main

import (
	"fmt"
)

func main() {
	x := uint(4294967295)
	fmt.Println(x * x)
	// Output (gc):       1
	// Output (GopherJS): 0
}

https://play.golang.org/p/gY-qQ51AyZ
https://gopherjs.github.io/playground/#/gY-qQ51AyZ

/cc @neelance

I found this because math/big changed type of big.Word from uintptr in Go 1.8 to uint in Go 1.9, and it broke the majority of its tests.

dmitshur added a commit that referenced this issue Jun 24, 2017
math/big package no longer has a bitLen low-level function,
so it can be removed.

In Go 1.9, the type of big.Word has changed from uintptr
to uint. Due to issue #652 with uint multiplication with
overflows, we use a workaround of overriding type of Word
back to uintptr. This should be undone once #652 is fixed.

Fixes:

	$ gopherjs test --short math/big
	$GOROOT/src/math/big/big.go:39:9: undeclared name: bitLen_g
dmitshur added a commit that referenced this issue Aug 25, 2017
math/big package no longer has a bitLen low-level function,
so it can be removed.

In Go 1.9, the type of big.Word has changed from uintptr
to uint. Due to issue #652 with uint multiplication with
overflows, we use a workaround of overriding type of Word
back to uintptr. This should be undone once #652 is fixed.

Fixes:

	$ gopherjs test --short math/big
	$GOROOT/src/math/big/big.go:39:9: undeclared name: bitLen_g
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant