reject_slice_to_array_ptr.mx raw

   1  // expected: slice-to-array-pointer conversion is not allowed
   2  //
   3  // Slices replace arrays; there is no slice-to-array machinery. (*[N]T)(s) on a
   4  // slice would hand back a pointer into slice storage with a fixed length the
   5  // runtime does not track, so it must be rejected instead of silently
   6  // reinterpreting the slice header.
   7  package main
   8  
   9  func main() {
  10  	s := []byte{1, 2, 3, 4}
  11  	p := (*[4]byte)(s)
  12  	println(int32(p[0]))
  13  }
  14