]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/5c: fix handling of side effects when assigning a struct literal.
authorRémy Oudompheng <oudomphe@phare.normalesup.org>
Sat, 12 Jan 2013 08:16:50 +0000 (09:16 +0100)
committerRémy Oudompheng <oudomphe@phare.normalesup.org>
Sat, 12 Jan 2013 08:16:50 +0000 (09:16 +0100)
Also undo revision a5b96b602690 used to workaround the bug.

Fixes #4643.

R=rsc, golang-dev, dave, minux.ma, lucio.dere, bradfitz
CC=golang-dev
https://golang.org/cl/7090043

src/cmd/5c/cgen.c
src/pkg/runtime/mgc0.c

index 9e74f515b040e9dc9617d3ea257103aa6e9a0471..5ff4f633d14ac10f8f5ca96589cb1eccce844f0e 100644 (file)
@@ -950,9 +950,9 @@ sugen(Node *n, Node *nn, int32 w)
 
        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 e39e10f93ccc75cb6a0bca4ec58dd2cd49b1d47c..b612e6216a00c0964321e1a0e2385671aef6b56c 100644 (file)
@@ -338,8 +338,7 @@ flushptrbuf(PtrTarget *ptrbuf, PtrTarget **ptrbufpos, Obj **_wp, Workbuf **_wbuf
                        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 @@ scanblock(Workbuf *wbuf, Obj *wp, uintptr nobj, bool keepworking)
                        
                        // 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 @@ scanblock(Workbuf *wbuf, Obj *wp, uintptr nobj, bool keepworking)
                                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 @@ scanblock(Workbuf *wbuf, Obj *wp, uintptr nobj, bool keepworking)
                }
 
                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);
                }