diff options
Diffstat (limited to 'src/cmd')
| -rw-r--r-- | src/cmd/compile/internal/types/size.go | 6 | ||||
| -rw-r--r-- | src/cmd/compile/internal/types2/stdlib_test.go | 1 |
2 files changed, 7 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/types/size.go b/src/cmd/compile/internal/types/size.go index 1acb041e35..4d64c7f8d2 100644 --- a/src/cmd/compile/internal/types/size.go +++ b/src/cmd/compile/internal/types/size.go @@ -366,6 +366,12 @@ func CalcSize(t *Type) { t.intRegs = 1 CheckSize(t.Elem()) CheckSize(t.Key()) + if t.Elem().width >= 1<<31 { + base.Errorf("map element type too large") + } + if t.Key().width >= 1<<31 { + base.Errorf("map key type too large") + } t.setAlg(ANOEQ) t.ptrBytes = int64(PtrSize) diff --git a/src/cmd/compile/internal/types2/stdlib_test.go b/src/cmd/compile/internal/types2/stdlib_test.go index 924b7b841f..6108155fc7 100644 --- a/src/cmd/compile/internal/types2/stdlib_test.go +++ b/src/cmd/compile/internal/types2/stdlib_test.go @@ -328,6 +328,7 @@ func TestStdFixed(t *testing.T) { "issue48230.go", // go/types doesn't check validity of //go:xxx directives "issue49767.go", // go/types does not have constraints on channel element size "issue49814.go", // go/types does not have constraints on array size + "issue78355.go", // types2 does not have constraints on map element size "issue56103.go", // anonymous interface cycles; will be a type checker error in 1.22 "issue52697.go", // types2 does not have constraints on stack size |
