Source file test/fixedbugs/issue59190.go

     1  // errorcheck
     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  package p
     8  
     9  import "unsafe"
    10  
    11  type E [1 << 30]complex128
    12  
    13  var a [1 << 30]E
    14  var _ = unsafe.Sizeof(a) // ERROR "too large"
    15  
    16  var s struct {
    17  	_ [1 << 30]E
    18  	x int
    19  }
    20  var _ = unsafe.Offsetof(s.x) // ERROR "too large"
    21  
    22  // Test case from issue (modified so it also triggers on 32-bit platforms).
    23  
    24  type A [1]int
    25  type S struct {
    26  	x A
    27  	y [1 << 30]A
    28  	z [1 << 30]struct{}
    29  }
    30  type T [1 << 30][1 << 30]S
    31  
    32  func _() {
    33  	var a A
    34  	var s S
    35  	var t T
    36  	_ = unsafe.Sizeof(a)
    37  	_ = unsafe.Sizeof(s)
    38  	_ = unsafe.Sizeof(t) // ERROR "too large"
    39  }
    40  

View as plain text