Index: src/cmd/5g/cgen.c |
=================================================================== |
--- a/src/cmd/5g/cgen.c |
+++ b/src/cmd/5g/cgen.c |
@@ -554,6 +554,21 @@ |
while(n->op == OCONVNOP) |
n = n->left; |
+ if(isconst(n, CTNIL) && n->type->width > widthptr) { |
+ // Use of a nil interface or nil slice. |
+ // Create a temporary we can take the address of and read. |
+ // The generated code is just going to panic, so it need not |
+ // be terribly efficient. See issue 3670. |
+ tempname(&n1, n->type); |
+ clearfat(&n1); |
+ regalloc(&n2, types[tptr], res); |
+ gins(ALEAQ, &n1, &n2); |
+ gmove(&n2, res); |
+ regfree(&n2); |
+ goto ret; |
+ } |
+ |
+ |
if(n->addable) { |
memset(&n1, 0, sizeof n1); |
n1.op = OADDR; |