-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: cannot convert uint to uintptr #13263
Comments
This is unrelated to the new parser; the same error appears with the old parser: |
Slightly simpler repro:
The problem is when staticassign is looking at the "z = uintptr(y)" node, it strips the OCONVNOP, finds the ONAME node for y, and then calls staticcopy(z, y, out). staticcopy(z, y, out) reaches the case ONAME, recursively calls staticcopy(z, x, out) which returns false (because x's Defn is nil), and then synthesizes a "z = x" assignment, which later fails typechecking. One fix seems to be to reinsert OCONVNOP nodes as necessary when generating that OAS node. |
This bug no longer seems to be an issue on Go1.6.2 at least. See https://play.golang.org/p/4GCc3_5qoT or inlined package main
import (
"fmt"
"runtime"
)
func f1() {
var (
w []*uint
x = *w[0]
y = x
z = (uintptr)(y)
)
fmt.Printf("z: %v\n", z)
}
func f2() {
var (
x uint
y = x
z = uintptr(y)
)
fmt.Printf("z: %v\n", z)
}
func main() {
fmt.Printf("Version: %s\n", runtime.Version())
} |
Still an issue with 1.7. |
@griesemer I am running |
Actually you are right(I stand corrected): with @dvyukov's test program with the global declarations it fails to compile but when I put them in functions, it compiles correctly. |
CL https://golang.org/cl/33900 mentions this issue. |
Reported offline by @cherrymui in my CL https://golang.org/cl/33900, the problem seems broader package a
var (
a uint
b = a
c = (uint64)(b)
) |
CL https://golang.org/cl/33970 mentions this issue. |
cmd/compile fails on the following correct program:
gotype eats it.
go version devel +25a28da Sun Nov 15 23:41:28 2015 +0000 linux/amd64
Found with GoSmith (https://github.com/dvyukov/gosmith).
The text was updated successfully, but these errors were encountered: