golang/go

cmd/compile, runtime: mishandling of out of range int->string conversions

mdempsky opened this issue · 4 comments

Go spec says:

Converting a signed or unsigned integer value to a string type yields a string containing the UTF-8 representation of the integer. Values outside the range of valid Unicode code points are converted to "\uFFFD".

  1. cmd/compile rejects string(1<<100) instead of yielding "\uFFFD": http://play.golang.org/p/1s6ge-XFqd (gccgo also rejects this; gotype accepts it.)
  2. runtime incorrectly truncates 64-bit integer values to uint32 before checking if they're a valid Unicode code point: http://play.golang.org/p/M_Gkll5VY-

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

Where is the gccgo bug?

Filed #15041 for gccgo.

This was a duplicate of #11330 which it fixed as well.