Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(152)

Unified Diff: src/cmd/5g/cgen.c

Issue 6542058: code review 6542058: cmd/gc: fix use of nil interface, slice (Closed)
Patch Set: diff -r 5a92a8a1509d https://code.google.com/p/go/ Created 12 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/cmd/6g/cgen.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « no previous file | src/cmd/6g/cgen.c » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b