1
0
mirror of https://github.com/golang/go synced 2024-11-26 08:48:13 -07:00

cmd/gc: make rnd() more 64-bit-friendly.

Fixes #4200.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6619057
This commit is contained in:
Rémy Oudompheng 2012-10-07 00:29:55 +02:00
parent bcccad4020
commit 94acfde22e
3 changed files with 25 additions and 3 deletions

View File

@ -15,8 +15,8 @@
static int defercalc; static int defercalc;
uint32 vlong
rnd(uint32 o, uint32 r) rnd(vlong o, vlong r)
{ {
if(r < 1 || r > 8 || (r&(r-1)) != 0) if(r < 1 || r > 8 || (r&(r-1)) != 0)
fatal("rnd"); fatal("rnd");

View File

@ -936,7 +936,7 @@ void checkwidth(Type *t);
void defercheckwidth(void); void defercheckwidth(void);
void dowidth(Type *t); void dowidth(Type *t);
void resumecheckwidth(void); void resumecheckwidth(void);
uint32 rnd(uint32 o, uint32 r); vlong rnd(vlong o, vlong r);
void typeinit(void); void typeinit(void);
/* /*

22
test/fixedbugs/bug458.go Normal file
View File

@ -0,0 +1,22 @@
// compile
// Copyright 2012 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.
// Issue 4200: 6g crashes when a type is larger than 4GB.
package main
import "unsafe"
// N=16 on 32-bit arches, 256 on 64-bit arches.
// On 32-bit arches we don't want to test types
// that are over 4GB large.
const N = 1 << unsafe.Sizeof(uintptr(0))
type T [N][10][10][10][10][3]byte
func F(t *T) byte {
return t[0][0][0][0][0][0]
}