]> Cypherpunks.ru repositories - gostls13.git/commit
[release-branch.go1.20] cmd/compile: do not report division by error during typecheck
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Thu, 8 Jun 2023 02:58:22 +0000 (09:58 +0700)
committerGopher Robot <gobot@golang.org>
Mon, 19 Jun 2023 23:11:17 +0000 (23:11 +0000)
commit63ad2b5811f712c6dc01184251d821d45b853d55
tree10c42ada0cfba6978d8799d3c3dc3c654cf30055
parent95f377daad6fcb8c52c568af7514d489741d715c
[release-branch.go1.20] cmd/compile: do not report division by error during typecheck

types2 have already errored about any spec-required overflows, and
division by zero. CL 469595 unintentionally fixed typecheck not to error
about overflows, but zero division is still be checked during tcArith.
This causes unsafe operations with variable size failed to compile,
instead of raising runtime error.

This CL also making change to typecheck.EvalConst, to stop evaluating
literal shifts or binary operators where {over,under}flows can happen.
For go1.21, typecheck.EvalConst is removed entirely, but that change is
too large to backport.

See discussion in CL 501735 for more details.

Fixes #60675

Change-Id: I7bea2821099556835c920713397f7c5d8a4025ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/501735
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/503855
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
src/cmd/compile/internal/typecheck/const.go
src/cmd/compile/internal/typecheck/expr.go
test/fixedbugs/issue60601.go [new file with mode: 0644]