blob: 179d9f44e95ed9c0d154611fe20c0704c467417d [file] [log] [blame]
Dan Willemsenbc60c3c2021-12-15 01:09:00 -08001// run -gcflags=-G=3
2
3// Copyright 2021 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 "fmt"
11 "unsafe"
12)
13
14type S[T any] struct {
15 val T
16}
17
18// Test type substitution where base type is unsafe.Pointer
19type U[T any] unsafe.Pointer
20
21func test[T any]() T {
22 var q U[T]
23 var v struct {
24 // Test derived type that contains an unsafe.Pointer
25 p unsafe.Pointer
26 val T
27 }
28 _ = q
29 return v.val
30}
31
32func main() {
33 want := 0
34 got := test[int]()
35 if got != want {
36 panic(fmt.Sprintf("got %f, want %f", got, want))
37 }
38
39}