#652·gopherjs

Bug in overflow multiplication of uint type.

Author: dmitshurCreated Jun 24, 2017Updated Aug 7, 2025
LabelsbugNeedsFix

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

It does not affect uintptr, nor uint32.

go
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.