aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/plugin.go
diff options
context:
space:
mode:
authorJorropo <jorropo.pgm@gmail.com>2026-03-24 20:42:41 +0100
committerGopher Robot <gobot@golang.org>2026-03-26 09:01:13 -0700
commit5edb5d729d14f0e036669e505548c899592a4d7c (patch)
tree7a3e926989afa247f712d574127c42b67e68a59a /src/runtime/plugin.go
parente4fcdc6c55bfdc90f4f42eefc4e97998de3ef4e7 (diff)
downloadgo-5edb5d729d14f0e036669e505548c899592a4d7c.tar.xz
cmd/compile: do not invert loops that would overflow or underflow
On the final iteration we need space below start (which becomes end) such that i-step does not overflow or underflow. In other words the code used to assume that the last time the loop header execute `start < i - step` (or `<=`, `>` `>=` based on the loop) is always false. And it seems correct since by definition the only way for it to be the last's loop header execution is when the condition becomes false. However here is an example with uint (even tho the code doesn't already support them) to make things simpler: start = 1 i = 2 step = 100 We do 2 - 100 which should give us 1 < -98 == false breaking the loop; Instead we get 18446744073709551518 which gives 1 < 18446744073709551518 == true which keeps the loop going. This patch fixes this issue by ensuring that in the last execution of a loop header the induction variable does not underflow or overflow. Fixes #78303 Change-Id: I64e8e8592b023d79fdbc7f1598d584726ed601f5 Reviewed-on: https://go-review.googlesource.com/c/go/+/758801 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Jorropo <jorropo.pgm@gmail.com> Reviewed-by: Jakub Ciolek <jakub@ciolek.dev> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/runtime/plugin.go')
0 files changed, 0 insertions, 0 deletions