mirror of
https://github.com/golang/go
synced 2024-11-25 14:37:56 -07:00
ac8127d7e6
The result of ODOTPTR, as well as a bunch of other ops, should be the type of the result, not always a pointer type. This fixes an amd64p32 bug where we were incorrectly truncating a 64-bit slice index to 32 bits, and then barfing on a weird load-64-bits-but-then-truncate-to-32-bits op that doesn't exist. Fixes #15252 Change-Id: Ie62f4315fffd79f233e5449324ccc0879f5ac343 Reviewed-on: https://go-review.googlesource.com/22094 Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
33 lines
612 B
Go
33 lines
612 B
Go
// run
|
|
|
|
// Copyright 2016 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// This test makes sure that we use all 64 bits of an
|
|
// index, even on 32 bit machines. It also tests that nacl
|
|
// can compile 64 bit indexes loaded from ODOTPTR properly.
|
|
|
|
package main
|
|
|
|
type T struct {
|
|
i int64
|
|
}
|
|
|
|
func f(t *T) byte {
|
|
b := [2]byte{3, 4}
|
|
return b[t.i]
|
|
}
|
|
|
|
func main() {
|
|
t := &T{0x100000001}
|
|
defer func() {
|
|
r := recover()
|
|
if r == nil {
|
|
panic("panic wasn't recoverable")
|
|
}
|
|
}()
|
|
f(t)
|
|
panic("index didn't panic")
|
|
}
|