modernc.org/gc@v1.0.1-0.20240304020402-f0dba7c97c2b/testdata/errchk/test/fixedbugs/issue15252.go (about)

     1  // run
     2  
     3  // Copyright 2016 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  // This test makes sure that we use all 64 bits of an
     8  // index, even on 32 bit machines.  It also tests that nacl
     9  // can compile 64 bit indexes loaded from ODOTPTR properly.
    10  
    11  package main
    12  
    13  type T struct {
    14  	i int64
    15  }
    16  
    17  func f(t *T) byte {
    18  	b := [2]byte{3, 4}
    19  	return b[t.i]
    20  }
    21  
    22  func main() {
    23  	t := &T{0x100000001}
    24  	defer func() {
    25  		r := recover()
    26  		if r == nil {
    27  			panic("panic wasn't recoverable")
    28  		}
    29  	}()
    30  	f(t)
    31  	panic("index didn't panic")
    32  }