1// run
2
3// Copyright 2022 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
7package main
8
9import (
10	"unsafe"
11)
12
13type Embedded struct {
14	B int
15}
16
17type S[K any] struct {
18	A K
19	Embedded
20}
21
22func showOffsets[K any](d *S[K]) {
23	o1 := unsafe.Offsetof(d.B)
24	o2 := unsafe.Offsetof(d.Embedded)
25	if o1 != o2 {
26		panic("offset mismatch")
27	}
28}
29
30func main() {
31	showOffsets(new(S[int]))
32}
33