Source file test/fixedbugs/issue62515.go

     1  // compile
     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  // Unified frontend generated unnecessary temporaries for expressions
     8  // within unsafe.Sizeof, etc functions.
     9  
    10  package main
    11  
    12  import "unsafe"
    13  
    14  func F[G int](g G) (uintptr, uintptr, uintptr) {
    15  	var c chan func() int
    16  	type s struct {
    17  		g G
    18  		x []int
    19  	}
    20  	return unsafe.Sizeof(s{g, make([]int, (<-c)())}),
    21  		unsafe.Alignof(s{g, make([]int, (<-c)())}),
    22  		unsafe.Offsetof(s{g, make([]int, (<-c)())}.x)
    23  }
    24  
    25  func main() {
    26  	F(0)
    27  }
    28  

View as plain text