From: Rémy Oudompheng Date: Tue, 4 Mar 2014 07:18:17 +0000 (+0100) Subject: cmd/gc: use a register to checknil constants. X-Git-Tag: go1.3beta1~495 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=52e6d7c6224612a3b60caa799bc22bd50ab16acb;p=gostls13.git cmd/gc: use a register to checknil constants. Fixes #7346. LGTM=rsc R=rsc, iant, khr CC=golang-codereviews https://golang.org/cl/69050044 --- diff --git a/src/cmd/gc/pgen.c b/src/cmd/gc/pgen.c index d05471ee30..f819f923cb 100644 --- a/src/cmd/gc/pgen.c +++ b/src/cmd/gc/pgen.c @@ -476,7 +476,7 @@ cgen_checknil(Node *n) dump("checknil", n); fatal("bad checknil"); } - if((thechar == '5' && n->op != OREGISTER) || !n->addable) { + if((thechar == '5' && n->op != OREGISTER) || !n->addable || n->op == OLITERAL) { regalloc(®, types[tptr], n); cgen(n, ®); gins(ACHECKNIL, ®, N); diff --git a/test/fixedbugs/issue7346.go b/test/fixedbugs/issue7346.go new file mode 100644 index 0000000000..dd5ea222f1 --- /dev/null +++ b/test/fixedbugs/issue7346.go @@ -0,0 +1,14 @@ +// compile + +// 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. + +// issue 7346 : internal error "doasm" error due to checknil +// of a nil literal. + +package main + +func main() { + _ = *(*int)(nil) +}