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

Compiler error "reg: unknown op: TESTL" when casting float to byte or uint16 #436

Closed
rsaarelm opened this issue Dec 16, 2009 · 2 comments
Closed

Comments

@rsaarelm
Copy link
Contributor

Before filing a bug, please check whether it has been fixed since
the latest release: run "hg pull -u" and retry what you did to
reproduce the problem.  Thanks.

What steps will reproduce the problem?
Try to compile the following program:
----
package main

import "fmt"

func Byte() {
    num := 10.1
    fmt.Println(byte(num))
}
----

What is the expected output? What do you see instead?

The program should compile. Instead I get a compiler error message:

sample.go:7: reg: unknown op: TESTL

What is your $GOOS?  $GOARCH?

linux 386

Which revision are you using?  (hg identify)

b0524afd0d7c tip

Please provide any additional information below.

The same error occurs if byte is substituted with uint16, but not with
int8, int16, uint32, int32, uint or int.
@rsaarelm
Copy link
Contributor Author

Comment 1:

A workaround is to use "byte(int(num))" instead of "byte(num)".

@rsc
Copy link
Contributor

rsc commented Dec 21, 2009

Comment 2:

This issue was closed by revision 4ab0ce1.

Status changed to Fixed.

Merged into issue #-.

@rsaarelm rsaarelm added the fixed label Dec 21, 2009
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
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