aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cmd/compile/internal/ssagen/ssa.go4
-rw-r--r--test/fixedbugs/issue77815.go20
2 files changed, 22 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/ssagen/ssa.go b/src/cmd/compile/internal/ssagen/ssa.go
index 37a0cbd881..849781c9ee 100644
--- a/src/cmd/compile/internal/ssagen/ssa.go
+++ b/src/cmd/compile/internal/ssagen/ssa.go
@@ -5670,7 +5670,7 @@ func (s *state) storeTypeScalars(t *types.Type, left, right *ssa.Value, skip ski
val := s.newValue1I(ssa.OpStructSelect, ft, int64(i), right)
s.storeTypeScalars(ft, addr, val, 0)
}
- case t.IsArray() && t.NumElem() == 0:
+ case t.IsArray() && t.Size() == 0:
// nothing
case t.IsArray() && t.NumElem() == 1:
s.storeTypeScalars(t.Elem(), left, s.newValue1I(ssa.OpArraySelect, t.Elem(), 0, right), 0)
@@ -5710,7 +5710,7 @@ func (s *state) storeTypePtrs(t *types.Type, left, right *ssa.Value) {
val := s.newValue1I(ssa.OpStructSelect, ft, int64(i), right)
s.storeTypePtrs(ft, addr, val)
}
- case t.IsArray() && t.NumElem() == 0:
+ case t.IsArray() && t.Size() == 0:
// nothing
case t.IsArray() && t.NumElem() == 1:
s.storeTypePtrs(t.Elem(), left, s.newValue1I(ssa.OpArraySelect, t.Elem(), 0, right))
diff --git a/test/fixedbugs/issue77815.go b/test/fixedbugs/issue77815.go
new file mode 100644
index 0000000000..9adc108498
--- /dev/null
+++ b/test/fixedbugs/issue77815.go
@@ -0,0 +1,20 @@
+// 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.
+
+package p
+
+type S struct {
+ a [4]struct{}
+ f chan int
+}
+
+func f(p *S) {
+ var s S
+
+ // Memory write that requires a write barrier should work
+ // with structs having zero-sized arrays of non-zero elements.
+ *p = s
+}