Skip to content

math/big: different subVV result on pure Go vs assembly implementations #41401

@SparrowLii

Description

@SparrowLii

Look at this test:

func SubVVTest(){
	z:=nat(nil).make(2)
	x:=nat([]Word{1})
	y:=nat([]Word{2})

	c1:=subVV(z,x,y)
	c2:=subVV_g(z,x,y)

	fmt.Println(c1)
	fmt.Println(c2)
}

c1 and c2 will get different results. The reason is that the length of x, y, z is not checked in the assembly code. Some other functions in arith.go have similar problems.
Three solutions:
(1) Remove the length check of x and y in subVV.
(2) Add length check in arith_$GOARCH.s files, though efficiency will become lower.
(3) Remove assembly functions and let the compiler consider these things.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions