1
0
mirror of https://github.com/golang/go synced 2024-11-21 20:34:40 -07:00

8g: make a[byte(x)] truncate x

R=ken2
CC=golang-dev
https://golang.org/cl/223069
This commit is contained in:
Russ Cox 2010-02-26 13:15:29 -08:00
parent 9520a68268
commit ba50599e46
2 changed files with 24 additions and 1 deletions

View File

@ -215,7 +215,14 @@ cgen(Node *n, Node *res)
break;
}
mgen(nl, &n1, res);
gmove(&n1, res);
if(n->type->width > widthptr)
tempname(&n2, n->type);
else
regalloc(&n2, n->type, res);
gmove(&n1, &n2);
gmove(&n2, res);
if(n2.op == OREGISTER)
regfree(&n2);
mfree(&n1);
break;

16
test/fixedbugs/bug259.go Normal file
View File

@ -0,0 +1,16 @@
// $G $D/$F.go && $L $F.$A && ./$A.out
// Copyright 2010 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.
package main
import "fmt"
var x = uint32(0x01020304)
var y = [...]uint32{1,2,3,4,5}
func main() {
fmt.Sprint(y[byte(x)])
}