-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
gccgo: bogus integer constant overflow #11525
Comments
I'm confused by this since it doesn't seem that (my versions of) either compiler accept this. The spec says this is valid if x is an integer constant and T is a string type, but x is not a valid integer constant; it overflows. I'm not sure why gccgo should compile the above program. |
The gc compiler also rejects this program: foo.go:2: overflow in int -> string I agree with Chris: I don't see why gccgo has to do anything here. |
@paranoiacblack This is an academic exercise at best, but the spec doesn't say that a constant argument must fit into an int (or int64). It just says that it must be an integer value, and that values outside the range result in the value "\uFFFD". go/types accepts this without errors. I don't think it matters much, but it seems easier to simply produce this constant string (at compile time) than reporting an error. |
CL https://golang.org/cl/13906 mentions this issue. |
When converting a signed or unsigned integer value into a constant string, if the integer does not fit into the Go "int" type, the string will become "\uFFFD." Fixes golang/go#11525. Reviewed-on: https://go-review.googlesource.com/13906 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@227395 138bc75d-0d04-0410-961f-82ee72b054a4
gccgo rejects to compile the following program:
The spec says:
gcc version 6.0.0 2015070 (experimental) (GCC)
The text was updated successfully, but these errors were encountered: