// slice.ptr
n := n.(*ir.ConvExpr)
v := s.expr(n.X)
- arrlen := s.constInt(types.Types[types.TINT], n.Type().Elem().NumElem())
+ nelem := n.Type().Elem().NumElem()
+ arrlen := s.constInt(types.Types[types.TINT], nelem)
cap := s.newValue1(ssa.OpSliceLen, types.Types[types.TINT], v)
s.boundsCheck(arrlen, cap, ssa.BoundsConvert, false)
- return s.newValue1(ssa.OpSlicePtrUnchecked, n.Type(), v)
+ op := ssa.OpSlicePtr
+ if nelem == 0 {
+ op = ssa.OpSlicePtrUnchecked
+ }
+ return s.newValue1(op, n.Type(), v)
case ir.OCALLFUNC:
n := n.(*ir.CallExpr)
/* */
*p // ERROR "removed nil check"
}
+
+func f11(x []byte) {
+ p := (*[0]byte)(x)
+ _ = *p // ERROR "generated nil check"
+ q := (*[4]byte)(x)
+ _ = *q // ERROR "removed nil check"
+}