diff --git a/src/cmd/compile/internal/reflectdata/alg.go b/src/cmd/compile/internal/reflectdata/alg.go index eb46ed84aa2..f74a42eac11 100644 --- a/src/cmd/compile/internal/reflectdata/alg.go +++ b/src/cmd/compile/internal/reflectdata/alg.go @@ -785,6 +785,9 @@ func (e *eqSigBuilder) build(t *types.Type) { // The generated loops are kind of inefficient as well, // so unroll the loop a bit. const unrollSize = 32 // make loop body compare around this many bytes + if et.Size() == 0 { + break // zero-size elements need no comparison + } unroll := max(1, unrollSize/et.Size()) // Do partial loops directly. for n%unroll != 0 { diff --git a/test/fixedbugs/issue77303.go b/test/fixedbugs/issue77303.go new file mode 100644 index 00000000000..995e73b034a --- /dev/null +++ b/test/fixedbugs/issue77303.go @@ -0,0 +1,19 @@ +// compile + +// Copyright 2026 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. + +// Issue 77303: compiler crash on array of zero-size ASPECIAL elements. + +package p + +type zeroSizeSpecial struct { + _ [0]float64 +} + +var x [3]zeroSizeSpecial + +func f() bool { + return x == x +}