title: InvalidUnsafeSlice layout: article
InvalidUnsafeSlice occurs when unsafe.Slice is called with a
pointer argument that is not of pointer type or a length argument
that is not of integer type, negative, or out of bounds.
It also occurs if it is used in a package compiled for a language
version before go1.17.
Example:
import "unsafe"
var x int
var _ = unsafe.Slice(x, 1)
Example:
import "unsafe"
var x int
var _ = unsafe.Slice(&x, float64(1))
Example:
import "unsafe"
var x int
var _ = unsafe.Slice(&x, -1)
Example:
import "unsafe"
var x int
var _ = unsafe.Slice(&x, uint64(1) {{raw "<"}}{{raw "<"}} 63)