...

Source file src/internal/types/testdata/fixedbugs/issue59190.go

Documentation: internal/types/testdata/fixedbugs

     1  // Copyright 2023 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package p
     6  
     7  import "unsafe"
     8  
     9  type E [1 << 30]complex128
    10  var a [1 << 30]E
    11  var _ = unsafe.Sizeof(a /* ERROR "too large" */ )
    12  
    13  var s struct {
    14  	_ [1 << 30]E
    15  	x int
    16  }
    17  var _ = unsafe.Offsetof(s /* ERROR "too large" */ .x)
    18  
    19  // Test case from issue (modified so it also triggers on 32-bit platforms).
    20  
    21  type A [1]int
    22  type S struct {
    23  	x A
    24  	y [1 << 30]A
    25  	z [1 << 30]struct{}
    26  }
    27  type T [1 << 30][1 << 30]S
    28  
    29  func _() {
    30  	var a A
    31  	var s S
    32  	var t T
    33  	_ = unsafe.Sizeof(a)
    34  	_ = unsafe.Sizeof(s)
    35  	_ = unsafe.Sizeof(t /* ERROR "too large" */ )
    36  }
    37  

View as plain text