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: int conversion ignored in shift operation #12677

Closed
kortschak opened this issue Sep 18, 2015 · 3 comments
Closed

cmd/compile: int conversion ignored in shift operation #12677

kortschak opened this issue Sep 18, 2015 · 3 comments
Milestone

Comments

@kortschak
Copy link
Contributor

When the two package program below is compiled using go1.5.1 (linux/amd64) the build fails with:

$ go build foo.go 
# command-line-arguments
./foo.go:6: invalid operation: 1 << uint(bar.f·2) (shift of type float64)
./foo.go:10: tempname called with nil type
./foo.go:10: cannot use autotmp_0001 (type int32) as type float64 in assignment

If the Bar function is included in main, the build completes successfully, which is the expected outcome. The build is also successful with go1.4.2, or if the expression within the float64() is evaluated into a temporary variable.

foo.go

package main

import (
    "fmt"

    "bar"
)

func main() {
    fmt.Println(bar.Baz(2))
}

bar/bar.go

package bar

func Baz(f int) float64 {
    return 1 / float64(int(1)<<(uint(f)))
}

See https://groups.google.com/d/topic/golang-nuts/IP1YIOd_PaY/discussion for background.

@ianlancetaylor ianlancetaylor added this to the Go1.6 milestone Sep 18, 2015
@ianlancetaylor
Copy link
Contributor

Seems to be a bug reading the import data.

kortschak added a commit to biogo/biogo that referenced this issue Sep 19, 2015
@kortschak
Copy link
Contributor Author

Bisected to f09887c.

The effect is abolished by -gcflags="-l".

@gopherbot
Copy link

CL https://golang.org/cl/17817 mentions this issue.

@rsc rsc closed this as completed in 91c8e5f Dec 16, 2015
@golang golang locked and limited conversation to collaborators Dec 29, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants