You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I passed a const to a function which leftshifts the argument so that non-zero bits drop off the top of the value. https://go.dev/play/p/LcFGn7DXuJ8
illustrates the problem. If I call swap(const) to initialize a global, the go1.20 compiler complains and fails. If I call swap(const) to initialize a local then go 1.20 compiles the code and it runs properly.
What did you expect to see?
The go 1.19 and earlier compilers compiled this code successfully. However the go 1.20 compiler complains about the calculation of X, the global, but not Y, the local.
What did you see instead?
Go 1.20 compiler errors, complaining that the result of the << overflows uint16. Which it does, but x, the argument to the << is also a uint16. So I don't think the compiler should be complaining at all, and if this is some change in go1.20, I think it should complain consistently in both cases.
The text was updated successfully, but these errors were encountered: