1. Dave Cheney
  2. go

Commits

Rémy Oudompheng  committed 49b4150

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

Fixes issue 4200.

R=golang-dev, dave, rsc
CC=golang-dev
http://codereview.appspot.com/6619057

  • Participants
  • Parent commits 311d011
  • Branches default

Comments (0)

Files changed (3)

File src/cmd/gc/align.c

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

File src/cmd/gc/go.h

View file
 void	defercheckwidth(void);
 void	dowidth(Type *t);
 void	resumecheckwidth(void);
-uint32	rnd(uint32 o, uint32 r);
+vlong	rnd(vlong o, vlong r);
 void	typeinit(void);
 
 /*

File test/fixedbugs/bug458.go

View file
+// 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]
+}