Unreviewed changes
1 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:
```
The name of the file: src/cmd/compile/internal/types2/const.go
Insertions: 1, Deletions: 0.
@@ -53,6 +53,7 @@
// Disable the length check for now, as calling constant.StringVal
// eagerly constructs the string and can lead to significant memory
// usage increase. We may want a StringLen function.
+ // TODO(go.dev/issue/78346): reenable the check.
if false && x.val.Kind() == constant.String && len(constant.StringVal(x.val)) > maxLen {
check.errorf(atPos(opPos), InvalidConstVal, "constant string too long (%d bytes > %d bytes)",
len(constant.StringVal(x.val)), maxLen)
```
```
The name of the file: src/go/types/const.go
Insertions: 1, Deletions: 0.
@@ -55,6 +55,7 @@
// Disable the length check for now, as calling constant.StringVal
// eagerly constructs the string and can lead to significant memory
// usage increase. We may want a StringLen function.
+ // TODO(go.dev/issue/78346): reenable the check.
if false && x.val.Kind() == constant.String && len(constant.StringVal(x.val)) > maxLen {
check.errorf(atPos(opPos), InvalidConstVal, "constant string too long (%d bytes > %d bytes)",
len(constant.StringVal(x.val)), maxLen)
```
Change information
Commit message:
cmd/compile, go/types: disable constant string size check
The go/constant and go/types packages try very hard not to eagerly
construct string constant. The length check now calls
constant.StringVal effectively on every string constant, which
eagerly constructs the strings and can cause it to use
significantly more memory. We may need a different mechanism to do
the length check, like a new API that returns the length without
constructing the string. For now, disable the code.
Updates #78346.
Change-Id: I46a9586614150e7d5353803904e101d808a683f5
Files:
- M src/cmd/compile/internal/types2/const.go
- M src/go/types/const.go
- M src/internal/types/testdata/fixedbugs/issue78346.go
Change size: S
Delta: 3 files changed, 11 insertions(+), 3 deletions(-)
Branch: refs/heads/master