]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: fix internal crash
authorRuss Cox <rsc@golang.org>
Tue, 4 Mar 2014 00:55:40 +0000 (19:55 -0500)
committerRuss Cox <rsc@golang.org>
Tue, 4 Mar 2014 00:55:40 +0000 (19:55 -0500)
TBR=ken2
CC=golang-codereviews
https://golang.org/cl/70200053

src/cmd/gc/typecheck.c
test/fixedbugs/issue7310.go [new file with mode: 0644]

index 05efab4040af39cf422a736a9707e2ecbd8b96b1..21021def9578dcafcdf9d55b0c2a91bd75b5de7e 100644 (file)
@@ -1358,6 +1358,8 @@ reswitch:
                        goto error;
                defaultlit(&n->left, T);
                defaultlit(&n->right, T);
+               if(n->left->type == T || n->right->type == T)
+                       goto error;
 
                // copy([]byte, string)
                if(isslice(n->left->type) && n->right->type->etype == TSTRING) {
diff --git a/test/fixedbugs/issue7310.go b/test/fixedbugs/issue7310.go
new file mode 100644 (file)
index 0000000..4a535a1
--- /dev/null
@@ -0,0 +1,15 @@
+// errorcheck
+
+// Copyright 2014 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.
+
+// Internal compiler crash used to stop errors during second copy.
+
+package main
+
+func main() {
+       _ = copy(nil, []int{}) // ERROR "use of untyped nil"
+       _ = copy([]int{}, nil) // ERROR "use of untyped nil"
+       _ = 1+true // ERROR "cannot convert true" "mismatched types int and bool"
+}