Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: incorrect runtime panic on switch statement involving generic slice/map/func type #53635

Closed
mdempsky opened this issue Jul 1, 2022 · 5 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@mdempsky
Copy link
Member

mdempsky commented Jul 1, 2022

https://go.dev/play/p/4Wa1-HERtli?v=gotip

This program should run silently and exit with success.

With Go 1.18 and tip, it silently miscompiles as a program that raises a runtime panic instead.

Normally, I'm of the opinion that silent miscompilations are severe issues that merit a backport and fix. But I think this case is very unlikely in practice. If anyone disagrees or thinks there's an easy way to fix the 1.18 frontend to handle this correctly (or at least ICE instead), feel free to speak up.

/cc @randall77 @dr2chase @cuonglm

@mdempsky mdempsky added the NeedsFix The path to resolution is known, but the work has not been done. label Jul 1, 2022
@mdempsky mdempsky added this to the Go1.20 milestone Jul 1, 2022
@cuonglm
Copy link
Member

cuonglm commented Jul 1, 2022

Could we just simply suppress the conversion to interface{} if type is not comparable?

@gopherbot
Copy link

Change https://go.dev/cl/415634 mentions this issue: cmd/compile: don't convert to interface{} for un-comparable types in generic switch

@mdempsky
Copy link
Member Author

mdempsky commented Jul 1, 2022

Could we just simply suppress the conversion to interface{} if type is not comparable?

Nice idea. I think that should work, yeah.

@cuonglm
Copy link
Member

cuonglm commented Jul 8, 2022

@gopherbot please backport this to go1.18

@gopherbot
Copy link

Backport issue(s) opened: #53752 (for 1.18).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases.

jproberts pushed a commit to jproberts/go that referenced this issue Aug 10, 2022
…generic switch

Fixes golang#53635

Change-Id: I41f383be8870432fc0d29fa83687911ddd8217f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/415634
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
@golang golang locked and limited conversation to collaborators Jul 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants