Skip to content
This repository has been archived by the owner on May 2, 2018. It is now read-only.

Commit

Permalink
cmd/gc: use a register to checknil constants.
Browse files Browse the repository at this point in the history
Fixes #7346.

LGTM=rsc
R=rsc, iant, khr
CC=golang-codereviews
https://golang.org/cl/69050044
  • Loading branch information
remyoudompheng committed Mar 4, 2014
1 parent 0a3bd04 commit 52e6d7c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cmd/gc/pgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(&reg, types[tptr], n);
cgen(n, &reg);
gins(ACHECKNIL, &reg, N);
Expand Down
14 changes: 14 additions & 0 deletions test/fixedbugs/issue7346.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit 52e6d7c

Please sign in to comment.