From: Russ Cox Date: Sat, 11 Sep 2010 19:47:56 +0000 (-0400) Subject: gc: const nil bug X-Git-Tag: weekly.2010-09-15~46 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=0acb63769c900aad6e8d7d4380f248ef40829c0b;p=gostls13.git gc: const nil bug Fixes #1073. R=ken2 CC=golang-dev https://golang.org/cl/2169043 --- diff --git a/src/cmd/gc/walk.c b/src/cmd/gc/walk.c index e51b750b6c..fc8f19ec13 100644 --- a/src/cmd/gc/walk.c +++ b/src/cmd/gc/walk.c @@ -261,6 +261,10 @@ walkdef(Node *n) yyerror("const initializer must be constant"); goto ret; } + if(isconst(e, CTNIL)) { + yyerror("const initializer cannot be nil"); + goto ret; + } t = n->type; if(t != T) { convlit(&e, t); diff --git a/test/const1.go b/test/const1.go index 427d61e59c..cf07055cfa 100644 --- a/test/const1.go +++ b/test/const1.go @@ -77,3 +77,5 @@ func main() { f(String) // ERROR "convert|wrong type|cannot|incompatible" f(Bool) // ERROR "convert|wrong type|cannot|incompatible" } + +const ptr = nil // ERROR "const.*nil"