You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the spec, out-of-range characters in character literals are illegal - it is
not explicit about what should happen when there are
out-of-range characters in strings. For the following program:
package main
func main() {
// println('\777') // this character is out of range
// These characters/strings should get out of range errors as well:
println('\U0010FFFF', 0x0010FFFF)
println('\U00110000', 0x00110000) // ERROR 'ilegal'
println([]int("\U0010FFFF")[0], 0x0010FFFF)
println([]int("\U00110000")[0], 0xFFFD) // ERROR 'illegal'
}
the output is as follows:
6g bug286.go && 6l bug286.6 && 6.out
1114111 1114111
1114112 1114112
1114111 1114111
65533 65533
Observations:
1) 6g correctly complains about '\777' being out of range
2) Since '\777' is illegal, '\U00110000' should be illegal as well, however, 6g
interprets it as the integer value 0x00110000
3) The string "\U00110000" is accepted, but the illegal code point is
converted to 0xFFFD - it be should illegal
4) gccgo accepts complains in one case but not the other.
5) One could argue that none of the character literal escapes should be illegal since
they just represent integer values. However, that only
makes things more complicated, and at the moment 6g appears to be doing the opposite.
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: