Skip to content

go/types: bad constant integer->string conversion for out-of-bounds integers #42790

@mdempsky

Description

@mdempsky

The package below statically converts the constant 1<<32 to a string (which should be "\uFFFD", because it's outside of the valid Unicode range). It then checks that the length matches the expected length (which is 3).

cmd/compile correctly accepts this package, but go/types and gccgo do not. go/types used to handle this correctly. I believe this is a regression introduced by CL 220844 (6052838).

package p
const _ = -uint(len(string(1<<32)) - len("\uFFFD"))

/cc @griesemer @ianlancetaylor

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions