mirror of
https://github.com/golang/go
synced 2024-09-15 22:20:06 +00:00
cmd/compile: fix compiler crash on recursive types
By setting both a valid size and alignment for broken recursive types, we can appease some more safety checks and prevent compiler crashes. Fixes #21882. Change-Id: Ibaa137d8aa2c2a9d521462f144d7016c4abfd6e7 Reviewed-on: https://go-review.googlesource.com/64430 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
9ee6f7b061
commit
bb2f0da23a
|
@ -176,6 +176,7 @@ func dowidth(t *types.Type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Width = 0
|
t.Width = 0
|
||||||
|
t.Align = 1
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
9
test/fixedbugs/issue21882.go
Normal file
9
test/fixedbugs/issue21882.go
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
// errorcheck
|
||||||
|
|
||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package p
|
||||||
|
|
||||||
|
type T [2]T // ERROR "invalid recursive type"
|
Loading…
Reference in a new issue