Skip to content

cmd/compile: miscompilation of min/max builtin #60982

Closed
@randall77

Description

@randall77
package main

func f(x int) int {
	if x >= 1000 {
		return max(x, 2000)
	}
	switch x {
	case 0:
		return 0
	case 1:
		return 1
	case 2:
		return 2
... 996 more cases ...
	case 999:
		return 999
	}
	return 0
}

This program causes the compiler to crash on tip. The problem stems from an incompatibility between how max is implemented and the phi placement algorithm we use for large functions (hence the need for all the switch cases to reproduce it).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions