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

x/mobile: bug: cannot use variable (untyped int constant) as int value in argument to fmt.Printf (overflows) #56453

Closed
benma opened this issue Oct 27, 2022 · 3 comments
Labels
FrozenDueToAge mobile Android, iOS, and x/mobile WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@benma
Copy link

benma commented Oct 27, 2022

Hi

Thanks for gomobile, we use it successfully since years for our Android app!

I recently had to workaround this compiler error, which seems to be a bug:

package foo

import "fmt"

func Foo() {
	const foo = 0xff000000
	fmt.Printf("%v", foo)
}
$ gomobile bind -target android .
foo.go:7:19: cannot use foo (untyped int constant 4278190080) as int value in argument to fmt.Printf (overflows)

Running the same code with go run ... prints the constant as expected.

I worked around it by typing the constant explicitly:

const foo uint32 = 0xff000000.

Anyone knows why this is happening?

@gopherbot gopherbot added the mobile Android, iOS, and x/mobile label Oct 27, 2022
@gopherbot gopherbot added this to the Unreleased milestone Oct 27, 2022
@changkun
Copy link
Member

@benma Could you also report what is your current environment by answering the following questions?

### What version of Go are you using (`go version`)?

<pre>
$ go version

</pre>

### Does this issue reproduce with the latest release?



### What operating system and processor architecture are you using (`go env`)?

<details><summary><code>go env</code> Output</summary><br><pre>
$ go env

</pre></details>

@changkun changkun added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Oct 27, 2022
@robpike
Copy link
Contributor

robpike commented Oct 27, 2022

I believe this program will work on a 64-bit platform but fail to compile on a 32-bit platform, as 0xff000000 overflows the range of positive signed 32-bit integers.

@benma
Copy link
Author

benma commented Oct 27, 2022

Actually that makes a lot of sense, thanks! Sorry for the noise.

@benma benma closed this as completed Oct 27, 2022
@golang golang locked and limited conversation to collaborators Oct 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge mobile Android, iOS, and x/mobile WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants