Skip to content

x/tools/go/ssa: misrepresents the dynamic behavior of shift with signed rhs #51363

@dominikh

Description

@dominikh

Input:

package main

func foo(x int) { _ = 1 << x }
func main()     { foo(-1) }

Output:

func foo(x int):
0:                                                                entry P:0 S:0
	t0 = convert uint64 <- int (x)                                   uint64
	t1 = 1:int << t0                                                    int
	return

Actual runtime behavior:

$ go run bar.go                                                                
panic: runtime error: negative shift amount

This issue is very similar to #50949, with much of the same possible fixes.

/cc @timothy-king

Metadata

Metadata

Assignees

No one assigned

    Labels

    AnalysisIssues related to static analysis (vet, x/tools/go/analysis)FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.ToolsThis label describes issues relating to any tools in the x/tools repository.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions