]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: make rnd() more 64-bit-friendly.
authorRémy Oudompheng <oudomphe@phare.normalesup.org>
Sat, 6 Oct 2012 22:29:55 +0000 (00:29 +0200)
committerRémy Oudompheng <oudomphe@phare.normalesup.org>
Sat, 6 Oct 2012 22:29:55 +0000 (00:29 +0200)
Fixes #4200.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6619057

src/cmd/gc/align.c
src/cmd/gc/go.h
test/fixedbugs/bug458.go [new file with mode: 0644]

index 2d3756dfc26157238a379d5e271d96fdd7a88792..36a33d48279d61189de90e7c2597f6b79a7e0684 100644 (file)
@@ -15,8 +15,8 @@
 
 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");
index 31fae5b19bd556e55b93635279d02a32709a194a..f6bf8ef8c2900ad947bc927571f6719ad3f68093 100644 (file)
@@ -936,7 +936,7 @@ void        checkwidth(Type *t);
 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);
 
 /*
diff --git a/test/fixedbugs/bug458.go b/test/fixedbugs/bug458.go
new file mode 100644 (file)
index 0000000..ddc97bd
--- /dev/null
@@ -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]
+}