1// run 2 3// Copyright 2023 The Go Authors. All rights reserved. 4// Use of this source code is governed by a BSD-style 5// license that can be found in the LICENSE file. 6 7// The gofrontend used to mishandle this code due to a pass ordering issue. 8// It was inconsistent as to whether unsafe.Sizeof(byte(0)) was a constant, 9// and therefore as to whether it was a direct-iface type. 10 11package main 12 13import "unsafe" 14 15type A [unsafe.Sizeof(byte(0))]*byte 16 17func (r A) V() byte { 18 return *r[0] 19} 20 21func F() byte { 22 panic("F") // should never be called 23} 24 25type B [unsafe.Sizeof(F())]*byte 26 27func (r B) V() byte { 28 return *r[0] 29} 30 31func main() { 32 b := byte(1) 33 v := A{&b}.V() + B{&b}.V() 34 if v != 2 { 35 panic(v) 36 } 37} 38