compiler: avoid silent truncation for string(1 << 32)

In the conversion of a constant integer to a string type, the value of
the constant integer was being silently truncated from unsigned long
to unsigned int, producing the wrong string value.  Add an explicit
overflow check to avoid this problem.

For golang/go#42790

Change-Id: I3407410bb02c24edd114e5f78a1f60ab66378656
Trust: Ian Lance Taylor <>
Reviewed-by: Matthew Dempsky <>
Reviewed-by: Than McIntosh <>
Reviewed-by: Cherry Zhang <>
1 file changed