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

Skip to content

Bug in overflow multiplication of uint type. #652

Open
@dmitshur

Description

@dmitshur

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions