From: Russ Cox Date: Tue, 4 Mar 2014 00:55:40 +0000 (-0500) Subject: cmd/gc: fix internal crash X-Git-Tag: go1.3beta1~501 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=56b983c112ddca28cf29e4d1b0ab9f590ea69976;p=gostls13.git cmd/gc: fix internal crash TBR=ken2 CC=golang-codereviews https://golang.org/cl/70200053 --- diff --git a/src/cmd/gc/typecheck.c b/src/cmd/gc/typecheck.c index 05efab4040..21021def95 100644 --- a/src/cmd/gc/typecheck.c +++ b/src/cmd/gc/typecheck.c @@ -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 index 0000000000..4a535a1fcc --- /dev/null +++ b/test/fixedbugs/issue7310.go @@ -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" +}