FAQ
Reviewers: rsc, golang-dev_googlegroups.com,

Message:
Hello rsc@golang.org, golang-dev@googlegroups.com (cc:
golang-dev@googlegroups.com),

I'd like you to review this change to
https://code.google.com/p/go


Description:
cmd/5c: fix handling of side effects when assigning a struct literal.

Also undo revision a5b96b602690 used to workaround the bug.

Fixes issue 4643.

Please review this at https://codereview.appspot.com/7090043/

Affected files:
M src/cmd/5c/cgen.c
M src/pkg/runtime/mgc0.c


Index: src/cmd/5c/cgen.c
===================================================================
--- a/src/cmd/5c/cgen.c
+++ b/src/cmd/5c/cgen.c
@@ -950,9 +950,9 @@

case OSTRUCT:
/*
- * rewrite so lhs has no fn call
+ * rewrite so lhs has no side effect.
*/
- if(nn != Z && nn->complex >= FNX) {
+ if(nn != Z && side(nn)) {
nod1 = *n;
nod1.type = typ(TIND, n->type);
regret(&nod2, &nod1);
Index: src/pkg/runtime/mgc0.c
===================================================================
--- a/src/pkg/runtime/mgc0.c
+++ b/src/pkg/runtime/mgc0.c
@@ -338,8 +338,7 @@
if((bits & (bitAllocated|bitMarked)) != bitAllocated)
continue;

- *bitbufpos = (BitTarget){obj, ti, bitp, shift};
- bitbufpos++;
+ *bitbufpos++ = (BitTarget){obj, ti, bitp, shift};
}

runtime·lock(&lock);
@@ -542,8 +541,7 @@

// iface->tab
if((void*)iface->tab >= arena_start && (void*)iface->tab < arena_used) {
- *ptrbufpos = (PtrTarget){iface->tab, (uintptr)itabtype->gc};
- ptrbufpos++;
+ *ptrbufpos++ = (PtrTarget){iface->tab, (uintptr)itabtype->gc};
if(ptrbufpos == ptrbuf_end)
flushptrbuf(ptrbuf, &ptrbufpos, &wp, &wbuf, &nobj, bitbuf);
}
@@ -570,8 +568,7 @@
stack_top.b += PtrSize;
obj = *(byte**)i;
if(obj >= arena_start && obj < arena_used) {
- *ptrbufpos = (PtrTarget){obj, 0};
- ptrbufpos++;
+ *ptrbufpos++ = (PtrTarget){obj, 0};
if(ptrbufpos == ptrbuf_end)
flushptrbuf(ptrbuf, &ptrbufpos, &wp, &wbuf, &nobj, bitbuf);
}
@@ -657,8 +654,7 @@
}

if(obj >= arena_start && obj < arena_used) {
- *ptrbufpos = (PtrTarget){obj, objti};
- ptrbufpos++;
+ *ptrbufpos++ = (PtrTarget){obj, objti};
if(ptrbufpos == ptrbuf_end)
flushptrbuf(ptrbuf, &ptrbufpos, &wp, &wbuf, &nobj, bitbuf);
}

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedJan 11, '13 at 7:12a
activeJan 11, '13 at 7:12a
posts1
users1
websitegolang.org

1 user in discussion

Remyoudompheng: 1 post

People

Translate

site design / logo © 2022 Grokbase