compiler: implement spec-compliant shifts

Previously, the compiler used LLVM's shift instructions directly, which have UB whenever the shifts are large or negative.
This commit adds runtime checks for negative shifts, and handles oversized shifts.
This commit is contained in:
Jaden Weiss
2020-03-28 12:35:19 -04:00
committed by GitHub
parent 91d1a23b14
commit 5cc130bb6e
6 changed files with 99 additions and 15 deletions
+5
View File
@@ -47,6 +47,11 @@ func chanMakePanic() {
runtimePanic("new channel is too big")
}
// Panic when a shift value is negative.
func negativeShiftPanic() {
runtimePanic("negative shift")
}
func blockingPanic() {
runtimePanic("trying to do blocking operation in exported function")
}