From 52e6d7c6224612a3b60caa799bc22bd50ab16acb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Oudompheng?= Date: Tue, 4 Mar 2014 08:18:17 +0100 Subject: [PATCH] cmd/gc: use a register to checknil constants. Fixes #7346. LGTM=rsc R=rsc, iant, khr CC=golang-codereviews https://golang.org/cl/69050044 --- src/cmd/gc/pgen.c | 2 +- test/fixedbugs/issue7346.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 test/fixedbugs/issue7346.go 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) +}