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

Unified Diff: src/cmd/6g/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 11 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 | « src/cmd/5g/cgen.c ('k') | src/cmd/6g/gsubr.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/cmd/6g/cgen.c
===================================================================
--- a/src/cmd/6g/cgen.c
+++ b/src/cmd/6g/cgen.c
@@ -518,6 +518,20 @@
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) {
regalloc(&n1, types[tptr], res);
gins(ALEAQ, n, &n1);
« no previous file with comments | « src/cmd/5g/cgen.c ('k') | src/cmd/6g/gsubr.c » ('j') | no next file with comments »

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